Cheap 3-D to 2-D Projection Matrix
Or the 2x3 Gerhold Projection Matrix
I show you how to multiply
three coordinates with three 2-d bases to move
left and right with cosine and up and down with sine
to the right spot, like on a piece of paper.
A 2-D ijk-Picture of a 3-D graph can be found
in the calc3book.pdf from mecmath.net.
That had let me think how to do that on the screen.
The following algorithm covers most of
the steps i figured out already to do the standard
transforms before projecting with this nice formula.
All three angles start at 0
α := x-Axis Angle
β := y-Axis Angle
γ := z-Axis Angle
:= Unit of the vectors
of the projection base.
should all have same size, .
else the thing stretch to a side
The projection is a 2x3 matrix.
I had the idea to use three two dimensional vectors.
The idea came from orthogonal bases and
the memory of the ijk-Notation Picture
showing the three base vectors on the axes.
Each column holds a base vector for x,y or z.
Instead of taking numbers i took the unit circle
In the following steps i first get the points.
Then i apply the local transformations.
x = points[i]
y = points[i+1]
z = points[i+2]
Apply a local 3x3 base
x = x*XBx+y*XBy+z*XBz
y = x*YBx+y*YBy+z*YBz
z = x*ZBx+y*ZBy+z*ZBz
Rotate the object
Do local translation to origin
x = Ox + Tx + x
y = Oy + Ty + y
z = Oz + Tz + z
O = Origin, T = Translation
Rotate the object around the world.
Apply the perspective to the points.
If i multiply the 3-D coordinates now
with P, i get the correct x' and y' for
the 2-D screen.
P*[x;y;z] = [x';y']
Ok, i have figured out transforms above, to
prove the work.
This here is the projection onto the screen:
x' = x*ux*Math.cos(α)|
y' = x*ux*Math.sin(α)|
Now i can shift the picture on the 2-D screen
by adding x' = origin2x + x' and
y' = origin2y + y'
Could apply the 2-D stuff on the image now.
The text of this document is not very good,
but i hope you get the point until here.
Will rewrite it technically