Asymptote: 3D graphics

Revision as of 00:32, 1 June 2011 by PythonNut (talk | contribs) (Created page with '{{Asymptote}} ==Three== Three is a module in Asymptote that allows the user to create three dimensional graphics. Usually all you must do is import three, then change from using …')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Asymptote (Vector Graphics Language)
Getting Started - Basics - Drawing - Labeling - Filling - Useful functions - Examples - Macros and Packages

Help - Reference - Advanced Asymptote - 3D Graphics - CSE5 Package - How to

Three

Three is a module in Asymptote that allows the user to create three dimensional graphics. Usually all you must do is import three, then change from using doubles to using triples as coordinates. Though some functions do not work when three is active. In order to fill a surface, for example, one must define a surface and draw that. instead of using filldraw. This is also described <url>http://www.artofproblemsolving.com/Forum/viewtopic.php?f=519&t=399845 here</url>.

Projection

You can use currentprojection=orthographic(x,y,z); To change current the view. currentprojection=perspective(x,y,z); Does the same thing, but is distorts the picture to copy actual viewing. Example: Using currentprojection=orthographic(1,1/2,1/2); We get a unit cube as: [asy] import three; currentprojection=orthographic(1,1/2,1/2);  draw(unitcube,palegrey); [/asy] Using currentprojection=perspective(1,1/2,1/2); We get a unit cube as: [asy] import three; currentprojection=perspective(1,1/2,1/2);  draw(unitcube,palegrey); [/asy]

Example

import three;
unitsize(1cm);
size(200);
currentprojection=perspective(1/3,-1,1/2);
draw((0,0,0)--(1,0,0)--(1,1,0)--(0,1,0)--cycle,red);
draw((0,0,0)--(0,0,1),red);
draw((0,1,0)--(0,1,1),red);
draw((1,1,0)--(1,1,1),red);
draw((1,0,0)--(1,0,1),red);
draw((0,0,1)--(1,0,1)--(1,1,1)--(0,1,1)--cycle,red);
draw((0,0,0)--(1,0,0)--(1,1,0)--cycle,red);
draw((0,0,0)--(1,1,0)--(1,1,1)--cycle,blue);
label("$o$",(0,0,0),NW);
label("$x=1$",(0.5,0,0),S);
label("$y=1$",(1,1,0.5),E);
label("$z=1$",(1,0.5,0),SE);
label("$c$",(0.5,0.5,0.5),N);[/asy]

Which renders to [asy] import three; unitsize(1cm); size(200); currentprojection=orthographic(1/3,-1,1/2); draw((0,0,0)--(1,0,0)--(1,1,0)--(0,1,0)--cycle,red); draw((0,0,0)--(0,0,1),red); draw((0,1,0)--(0,1,1),red); draw((1,1,0)--(1,1,1),red); draw((1,0,0)--(1,0,1),red); draw((0,0,1)--(1,0,1)--(1,1,1)--(0,1,1)--cycle,red); draw((0,0,0)--(1,0,0)--(1,1,0)--cycle,red); draw((0,0,0)--(1,1,0)--(1,1,1)--cycle,blue); label("$o$",(0,0,0),NW); label("$x=1$",(0.5,0,0),S); label("$y=1$",(1,1,0.5),E); label("$z=1$",(1,0.5,0),SE); label("$c$",(0.5,0.5,0.5),N);[/asy]

Other 3D Modules

Other modules in Asymptote that are for 3D are: graph3, grid3, contour3