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

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re: 3D Point Plotting by Merlin42
in thread 3D Point Plotting by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2023-02-06 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?