3d to 2d mapping


M

Miguel De Anda

I'm trying to write a little script that draws dots into a 3d space. It is
very small and has only 30 dots (5 by 6). These dots are on fixed x, y
positions but I need to position them on various z positions. I want to make
the z axis to be vertical (on the screen) and the x to be to the right (and
down a little bit) and the y to be back into the screen (and right a little
bit). I took a linear algebra class that covered how to do such
transformations but my brother has the book right now. Can anybody help me?
I simply need some matrix or something that I can multiply my [x, y, z] by
to get my new [x, y] positions that would appear to be in 3d on the screen.
This is just going to be for a demo that I need to do. Thanks.
 
Ad

Advertisements

P

pete kirkham

Miguel said:
I'm trying to write a little script that draws dots into a 3d space. It is
very small and has only 30 dots (5 by 6). These dots are on fixed x, y
positions but I need to position them on various z positions. I want to make
the z axis to be vertical (on the screen) and the x to be to the right (and
down a little bit) and the y to be back into the screen (and right a little
bit). I took a linear algebra class that covered how to do such
transformations but my brother has the book right now. Can anybody help me?
I simply need some matrix or something that I can multiply my [x, y, z] by
to get my new [x, y] positions that would appear to be in 3d on the screen.
This is just going to be for a demo that I need to do. Thanks.

From a quick google,
http://pages.infinit.net/jstlouis/3dbhole/mathematics_of_3d_graphics.html#Transformations
has some sample transformation matrices which will do.

Take your 3d point, translate and rotate so the translated x and y axes
align to your screen x and y (eg: rot X 90, rot Y ~10, rot X ~10 for Z
up, X right and down a bit, translate by <[screen-width - mean
X]/2,[screen-height - mean Y]/2, [distance-to-eye + lowest-z]> will give
about what you describe) , then (optionally) divide by the transformed z
value for perspective, not plottin all points whose z-values are greater
than the distance from the eye to the screen.

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top