Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: 3D Point Plotting

by Merlin42 (Friar)
on May 28, 2002 at 16:12 UTC ( #169812=note: print w/replies, xml ) Need Help??


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
  1. throw out points outside this box (cull/clip)
  2. divide by Z (projection)
  3. 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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://169812]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (6)
As of 2023-01-30 18:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?