# Orthographic projection in 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?

-

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.

-
Excellent .. But this method is not working inside a latex document. For example \documentclass{article} \usepackage{asymptote} \begin{document} \begin{figure} \begin{asy}[width=10cm,height=10cm] THE ASY CODE \end{asy} \end{figure} \end{document} 1. It is working when the sample.asy consists of only THE ASY CODE. How to solve this issue ? 2. It would be nice to have that interactive viewer accessible from within Texmaker. –  cosmicraga May 4 at 10:20