# What exactly is the orthographic projection used by Matlab

I would like to imitate the orthographic projection that Matlab uses by default:

Matlab View Projections

and

Matlab camproj

It seems similar to the "Trimetric" projection described here:

Wikipedia on Orthographic Projection

see the picture here:

Wikipedia picture - Comparison of projections

but I don't know whether they are definitely the same. Does anyone know the exact details of the Matlab projection ?

Thank you !

All of the above. If you look on matlabs page a little further down, it becomes apparent that matlab initializes a canvas (the screen), then looks for each pixel what is directly behind that screen. This gets rid of perspective. When you set the camera angle to 45 degrees down and 45 degrees left/right, you will get an implicit isometric projection. So really the "projection" just depends on your camera angle.

Sidenote: if you would want to keep a 3d perspective, you would need to draw the ray from the camera origin to the position on the canvas. That gives the ray the direction it needs to create perspective.

It's tricky because there are 2 non-uniform scales called "DataAspectRatio" and "PlotBoxAspectRatio". I worked through a simple case in the answer to this post, but I'm afraid that doesn't cover all of the edge cases.

All of these projections fall under the generic group of projections called "Axonometric" projections. The general goal of an axonometric projection is to manipulate the object using rotations and translations such that at least three adjacent faces of the projected object are shown. The result is projected from the center at infinity onto one of the coordinate planes usually the Z=0 plane. There are three common types of axonometric projections, trimetric, dimetric and isometric. With trimetric being the most general, dimetric is a specialization of trimetric with two of the three foreshortening factors being equal to each other, and isometric is a specialization of dimetric with the third foreshortening factor set equal to the other two (so all three are equal). Also note that the projection plane in this case is the Z plane. The matrix show below can be modified to use any of the X, Y or Z planes as the projection plane.

The general matrix form of all three (since dimetric and isometric are specializations of trimetric) is:

$$\begin{bmatrix} &cos\phi &sin\phi sin\theta &0 &0 \\ &0 &cos\theta &0 &0 \\ &sin\phi &-cos\phi sin\theta &0 &0 \\ &0 &0 &0 &1 \end{bmatrix}$$

Where phi is the rotation around the y axis and theta is the rotation around the x axis. The foreshortening length of each axis can be computed just by taking the sum of the squares of each row. Then take the square root to get the length. For the X axis this would be:

$$\begin{equation} f_{x}^{2} = cos^{2}\phi + sin^{2}\phi sin^{2}\theta \end{equation}$$

A little bit of algebra will yield the values needed to compute the lengths of the other 2.

To determine a trimetric projection all we need are the two viewing angles. For a diametric or isometric view we need to set the foreshortening factors equal to either two or three of the axis. By using the lengths of the rows and setting them equal to one another then solving we can compute any of the values needed for either projection.