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
- 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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.