3D
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6711
- Joined: Thu Dec 18, 2003 7:03 pm
3D
I'm interested in learning about 2D representation of 3D vectors. Nothing complicated, I just want to take my point in 3d and plop it on the 2d screen of my calculator. I'm just a bit hazy on the math I should be using... Any help from any of ye math/programming whizzes here?
The easiest thing to do is just an orthogonal, parallel projection along an axis: you drop one coordinate.
(x,y,z) -> (x,z)
The next thing to try would be a skewed parallel projection:
(x,y,z) -> (x + az, y + bz)
where a and b are arbitrary parameters (best in the range -0.5...0.5. This is handy for plotting 3d graphs, but as the name suggests, skews angles. You could go for isometric projection:
(x,y,z) -> ( a(x - z), y + b (x+z) ) with a = sin(60 degrees), b = cos(60 degrees).
It can be seen as a rotation, then an orthogonal, parallel projection (plus a scaling).
And then come the mappings that produce perspective, for confusing math reasons, they are called "projective". The simplest one is
(x,y,z) -> f (x/z, y/z)
Where it is assumed that the output (0,0) lies in the center of the screen, the corners are at (+/-1, +/-1). tan(1/f) is the field of view.
More of them can be indeed found in the OpenGL spec, but probably the parallel projections are sufficient for calculator graphics.
(x,y,z) -> (x,z)
The next thing to try would be a skewed parallel projection:
(x,y,z) -> (x + az, y + bz)
where a and b are arbitrary parameters (best in the range -0.5...0.5. This is handy for plotting 3d graphs, but as the name suggests, skews angles. You could go for isometric projection:
(x,y,z) -> ( a(x - z), y + b (x+z) ) with a = sin(60 degrees), b = cos(60 degrees).
It can be seen as a rotation, then an orthogonal, parallel projection (plus a scaling).
And then come the mappings that produce perspective, for confusing math reasons, they are called "projective". The simplest one is
(x,y,z) -> f (x/z, y/z)
Where it is assumed that the output (0,0) lies in the center of the screen, the corners are at (+/-1, +/-1). tan(1/f) is the field of view.
More of them can be indeed found in the OpenGL spec, but probably the parallel projections are sufficient for calculator graphics.
- Tank Program
- Forum & Project Admin, PhD
- Posts: 6711
- Joined: Thu Dec 18, 2003 7:03 pm