Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   3d to 2d mapping (http://www.velocityreviews.com/forums/t123787-3d-to-2d-mapping.html)

 Miguel De Anda 06-27-2003 09:22 PM

3d to 2d mapping

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.

 pete kirkham 06-27-2003 10:28 PM

Re: 3d to 2d mapping

Miguel De Anda wrote:

> 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.
>
>

http://pages.infinit.net/jstlouis/3d...ransformations
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

 All times are GMT. The time now is 10:50 PM.