[Tex/LaTex] Orthographic projection in asymptote

asymptote

I need assistance in understanding orthographic projection in asymptote.

currentprojection=orthographic(x,y,z);

Specifying x, y and z, one can rotate the figure in 3D but how do I decide on these numbers?

Best Answer

Changes in x, y and z will not rotate the 3d object, rather the camera position will be changed. A simple procedure can help to set up the projection parameters:

First, set the 2d size of the picture, e.g.

size(200);

Next, import some of the modules, that support 3d:

import three;

Start with some values for the camera position, imagine that this is a corner of the box, from which you are looking at the origin.

currentprojection=orthographic(2,2,2);

Place a simple object to start, e.g. a unit coordinate lines at the origin:

draw(O--(1,0,0),red);
draw(O--(0,1,0),green);
draw(O--(0,0,1),blue);

Now, you can run this sample.asy file:

size(200);
import three;
currentprojection=orthographic(2,2,2);   
triple O=(0,0,0);    
dot(O);
label("$O$",(0,0,0),N);    
draw(O--(1,0,0),red);
draw(O--(0,1,0),green);
draw(O--(0,0,1),blue);

with asy -V sample.asy > ocamera.asy. An interactive viewer will let you change the view point as you like, and then right-double-click will bring a menu. Click Camera and current camera settings will be saved in ocamera.asy file, looking something like:

currentprojection=orthographic(
camera=(0.961388410434579,3.28630597183905,-0.564352559252),
up=(0.000558361334852193,0.00103708683243738,0.00699025170673149),
target=(7.76288755499621e-17,7.76288755499621e-17,7.76288755499621e-17),
zoom=0.505067952995518);

which can be copied into sample.asy and edited, for example, like this:

currentprojection=orthographic(
camera=(1,3.3,-0.5),
up=(0,0,1),
target=(0,0,0),
zoom=0.5);

This will give you a starting point.

Related Question