3D

Everything todo with programming goes HERE.
Post Reply
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

3D

Post by Tank Program »

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?
Image
User avatar
Lucifer
Project Developer
Posts: 8641
Joined: Sun Aug 15, 2004 3:32 pm
Location: Republic of Texas
Contact:

Post by Lucifer »

I take it your calculator doesn't support OpenGL? :P
Image

Be the devil's own, Lucifer's my name.
- Iron Maiden
User avatar
Jonathan
A Brave Victim
Posts: 3391
Joined: Thu Feb 03, 2005 12:50 am
Location: Not really lurking anymore

Post by Jonathan »

You could look it up in the OpenGL spec. I think "coordinate transformations" is most useful.
ˌɑrməˈɡɛˌtrɑn
User avatar
Z-Man
God & Project Admin
Posts: 11589
Joined: Sun Jan 23, 2005 6:01 pm
Location: Cologne
Contact:

Post by Z-Man »

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.
User avatar
Tank Program
Forum & Project Admin, PhD
Posts: 6711
Joined: Thu Dec 18, 2003 7:03 pm

Post by Tank Program »

Hmm, thanks. I'll have to mess with it.
Image
Post Reply