ergetgetagt

Page 134

Chapter 8: Base modules

129

and then distorted into a saddle: import three; size(100,0); path3 g=(1,0,0)..(0,1,1)..(-1,0,0)..(0,-1,1)..cycle; draw(g); draw(((-1,-1,0)--(1,-1,0)--(1,1,0)--(-1,1,0)--cycle)); dot(g,red);

Module three provides constructors for converting two-dimensional paths to threedimensional ones, and vice-versa: path3 path3(path p, triple plane(pair)=XYplane); path path(path3 p, pair P(triple)=xypart); A Bezier surface, the natural two-dimensional generalization of Bezier curves, is defined in three_surface.asy as a structure containing an array of Bezier patches. Surfaces may drawn with one of the routines void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material surfacepen=currentpen, pen meshpen=nullpen, light light=currentlight, light meshlight=light, string name="", render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen meshpen, light light=currentlight, light meshlight=light, string name="", render render=defaultrender); void draw(picture pic=currentpicture, surface s, int nu=1, int nv=1, material[] surfacepen, pen[] meshpen=nullpens, light light=currentlight, light meshlight=light, string name="", render render=defaultrender); The parameters nu and nv specify the number of subdivisions for drawing optional mesh lines for each Bezier patch. The optional name parameter is used as a prefix for naming the surface patches in the PRC model tree. Here material is a structure defined in three_ light.asy: struct material { pen[] p; // diffusepen,ambientpen,emissivepen,specularpen real opacity; real shininess; ...


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.