Difference between revisions of "Asymptote: Crash Course"
5849206328x (talk | contribs) m (→Current projection) |
m (undoing vandalism) |
(One intermediate revision by one other user not shown) | |
(No difference)
|
Latest revision as of 19:22, 15 December 2020
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:
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:
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).