Asymptote: Crash Course
Current projection
Suppose you are floating in a three-dimensional universe that extends infinitely in each direction. A bright source of light illuminates the scene. You can move freely around this universe, enabling you to see everything in different perspectives.
At this point, there is a giant grid with a sphere on it. From your point of view, it looks like this:
<asy2>size(300);
import three;
currentprojection = perspective(1.7,0.5,0.6); currentlight = Viewport;
for (int i=-20; i<=10; i+=1)
draw((i,-20,0)--(i,10,0));
for (int j=-20; j<=10; j+=1)
draw((-20,j,0)--(10,j,0));
draw(scale(2,2,2)*unitsphere, red); </asy2>
This is what perspective projection is like. Basically, it is as if you were floating in this universe looking at the object with your own eyes. Closer objects are larger than farther objects, parallel lines converge, and, most importantly, I don't get dizzy.
Now, suppose you wore glasses that nuked your sense of perspective and replaced it with a different world, a world where parallel lines stay parallel and closer objects are of the same size as farther objects. This is what you'd see:
<asy2>size(300);
import three;
currentprojection = orthographic(1.7,0.5,0.6); currentlight = Viewport;
for (int i=-20; i<=10; i+=1)
draw((i,-20,0)--(i,10,0));
for (int j=-20; j<=10; j+=1)
draw((-20,j,0)--(10,j,0));
draw(scale(2,2,2)*unitsphere, red); </asy2>
This, my friends, is orthographic projection. It's not natural, but it's very useful when you want everything to be at the same scale, regardless of distance.
So now that we've figured out exactly what the heck are perspective and orthogonal projection, let's find out how to do it in Asymptote.
Declaring projection is easy:
// Perspective currentprojection = perspective(camera=(x,y,z)); // Orthographic currentprojection = orthographic(camera=(x,y,z));
Here, camera=(x,y,z) states the position of the camera, whose viewpoint the reader sees the drawing from. In our hypothetical universe, this would be the exact same thing as defining your position. Asymptote dictates that the -axis faces up, which, needless to say, is interesting:
In any case, use currentprojection lightly. Asymptote will try to find the best projection for you, so only use it if you want to see your drawing from a different angle, or if you want to change the mode (e.g. perspective to orthographic).