# Drawing 3D filled triangle with parabolic edges in Asymptote

I need to draw a filled 3D triangle that is curved on the interior. I wish to have parabolic edges and a smooth NURBS presentation and not a collection of small triangles on the interior of the triangle. The information that I have for the triangle are the (x,y,z) locations of the three corners and the three mid-edges. Any advise would be greatly appreciated!

``````import three;
settings.render=8;
size(10cm);
currentprojection=perspective(50,80,50);

// Rational Bezier patch: // udegree=3, vdegree=3, nu=4, nv=4;

real[] uknot={0,0,0,0,1,1,1,1};
real[] vknot={0,0,0,0,1,1,1,1};
triple[][] P=scale3(20)*octant1.P;

// Optional weights:
real[][] weights=array(P.length,array(P.length,1.0));

write("P=");
write(P);

draw(P,uknot,vknot,weights,gray);
``````

The above was a sample code that I found and edited from the web produces the image shown below. I printed the "P" variable data, but I don't understand it's meaning.

``````P=
(20,0,0)    (20,0,11.0456949966159) (11.0456949966159,0,20) (0,0,20)
(20,11.0456949966159,0) (20,11.0456949966159,11.0456949966159)  (11.0456949966159,6.10036889791324,20)  (0,0,20)
(11.0456949966159,20,0) (11.0456949966159,20,11.0456949966159)  (6.10036889791324,11.0456949966159,20)  (0,0,20)
(0,20,0)    (0,20,11.0456949966159) (0,11.0456949966159,20) (0,0,20)
``````

Are these point the control point for the Nurbs surface? The problem that I want to display would be to provide a curved triangle like in that example, but I would only need to use the corner and mid-edge points to the triangle. Any help would be appreciated! Thanks, Joe

• Can you edit your question to include a sketch of what you want? For example, I don't understand how a "filled 3D triangle" can be "curved on the interior". Do you mean that the interior fill will not lie on the same plane as the triangle vertices? – James May 16 '17 at 17:56
• Thanks James, import three; size(10cm); currentprojection=perspective(50,80,50); // Rational Bezier patch: // udegree=3, vdegree=3, nu=4, nv=4; real[] uknot={0,0,0,0,1,1,1,1}; real[] vknot={0,0,0,0,1,1,1,1}; triple[][] P=scale3(20)*octant1.P; // Optional weights: real[][] weights=array(P.length,array(P.length,1.0)); write("P="); write(P); draw(P,uknot,vknot,weights,gray); – JJQuigley May 16 '17 at 18:02
• The above was a sample code that I found and edited from the web. I printed the "P" variable data, but I don't understand it's meaning. Are these point the control point for the Nurbs surface? The problem that I want to display would be to provide a curved triangle like in that example, but I would only need to use the corner and mid-edge points to the triangle. Nay help would be appreciated! – JJQuigley May 16 '17 at 18:05
• I have incorporated your code and the resulting image into your question. Unfortunately, I can't answer your question as I'm not a big user of 3D. I'm sure someone else will be able to help. Good luck! – James May 16 '17 at 18:21

The `triple[][] P` defines the control points of the Bézier patch. For your question, the corner and mid-edge points are not sufficient to define a unique Bézier patch. I tried to answer using Asymptote routines in the same spirit of the octant definition (see `three_surface.asy`). With a `path3` of length =<4 (and without any internal points, optional) it is possible to construct the surface.

Here an attempt

``````import three;
settings.render=8;
size(10cm);
currentprojection=perspective(50,80,50);

triple A=(0,1,0);
triple B=(1,0,0);
triple MAB=(.6,.6,0); //mid-edge (AB)
triple C=(0,0,1);
triple MAC=(0,.6,.6); // mid-edge
triple MBC=(.7,0,.7); //mid-edge

path3 gc1=(A..MAB..B); //to avoid computation
path3 gc2=(B..MBC..C); // I use asymptote path3 routine
path3 gc3=(C..MAC..A);
// I recover the different tangents in A, B, C
// to construct a cycle-path3 of length 3.
path3 gc=point(gc1,0){dir(gc1,0)}..{dir(gc1,2)}point(gc1,2){dir(gc2,0)}
..{dir(gc2,2)}point(gc2,2){dir(gc3,0)}..{dir(gc3,2)}point(gc3,2)..cycle;

draw(surface(patch(gc)),lightgray);

draw(gc1^^gc2^^gc3);
dot((gc1^^gc2^^gc3),red);
``````

Please test and improve the code.

O.G.

• Hello O.G. Thank you very much! This was a great help to me and my research. Joe – JJQuigley May 17 '17 at 12:57