in reply to 3D Point Plotting
I know you asked for a module, but this can be done very simply .. as long as you only want to do simple stuff :).
If you are only interested in doing 3d points and have a static projective camera pointed along the Z axis then you can use the old 'divide by Z' trick. This is what is used in the classic 'flying stars/windows' screen saver. Lets say you are interested in veiwing some points inside a 3d cube of dimensions x1 to x2 by y1 to y2 by z1 to inf
ie
for each point x,y,z
x2d=x/z; y2d=y/z
Xviewport=(x2d-x1/z1)*(x2-x1)/z1*image_width
Yviewport=(y2d-y1/z1)*(y2-y1)/z1*image_height
plot Xviewport,Yviewport into the bitmap
NOTE: This is off the top of my head so it might be utter jiberish
NOTE: You could add one step b4 the cull/clip to transform your points so that they can be viewed along the z axis. This can be done w/ a 3x3 matrix multiply and a vector add(or with a 4x4 matrix mult ala OpenGL).
NOTE: If you prescale Z by some factor you can get different "zooms"
NOTE: If you want an orthographic projection, more like engineering diagrams/bluerpints then just skip all the divides and just thow away Z.
If you are only interested in doing 3d points and have a static projective camera pointed along the Z axis then you can use the old 'divide by Z' trick. This is what is used in the classic 'flying stars/windows' screen saver. Lets say you are interested in veiwing some points inside a 3d cube of dimensions x1 to x2 by y1 to y2 by z1 to inf
- throw out points outside this box (cull/clip)
- divide by Z (projection)
- scale to viewport
ie
for each point x,y,z
x2d=x/z; y2d=y/z
Xviewport=(x2d-x1/z1)*(x2-x1)/z1*image_width
Yviewport=(y2d-y1/z1)*(y2-y1)/z1*image_height
plot Xviewport,Yviewport into the bitmap
NOTE: This is off the top of my head so it might be utter jiberish
NOTE: You could add one step b4 the cull/clip to transform your points so that they can be viewed along the z axis. This can be done w/ a 3x3 matrix multiply and a vector add(or with a 4x4 matrix mult ala OpenGL).
NOTE: If you prescale Z by some factor you can get different "zooms"
NOTE: If you want an orthographic projection, more like engineering diagrams/bluerpints then just skip all the divides and just thow away Z.
|
---|
In Section
Seekers of Perl Wisdom