Re: A89: How to turn a 3d voxel into a 2d pixel
[Prev][Next][Index][Thread]
Re: A89: How to turn a 3d voxel into a 2d pixel
>I am having difficulty understanding how you convert the x,y,z so it
>will become x,y. Such code is neccesary in a raytracing proggram.
You may have already figured this out but here it goes.
My program for the 83 took the x and y coords, then moved them towards the
center of the screen by a linear function of z. It looked pretty good, but
thats not too accurate. The way most things do it:
+ <-- the point
\
\ | ^
\ | | +X
\ | |
| |
| \ |
<----------0----------|--+ <-- the viewer lies on the origin
+Z |
| <-- the screen of the calculator
If this drawing makes any sence -- which it probably doesn't -- you should
see what to do. Since you want to project the 3D vectors onto a 2D screen
you just cut them off when they meet the screen. The 0 on the Z axes is
what your points would call zero. You then need to internally shift the
point over by some distance so that <0,0,0> is the point of the observer
and <0,0,8?> would be your origin. Then you think of your point <x,y,z>
not as a point but as a vector. So if your screen is at Z=a you multiply
the x and y coords of the point by a/z to get the the <x,y> that goes on
the screen.
--Nate
References: