Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: 3D Point Plotting

by rbc (Curate)
on May 28, 2002 at 17:08 UTC ( #169839=note: print w/replies, xml ) Need Help??

in reply to 3D Point Plotting

You might want to see if this is what you are looking for

simple 3D graphics

The script in this link demonstrates how to draw a cube
and perform rotation and translations on it.

Replies are listed 'Best First'.
Re: Re: 3D Point Plotting
by Anonymous Monk on May 28, 2002 at 21:52 UTC
    rbc, thanks, but that script works with Tk... which isn't really applicable in the context of CGI, as far as I know... gnuplot looks like it might do the trick, but I'll have to play around with it a bit more. And as to your suggestion, Merlin42, very interesting but a bit beyond me, for now (still interested though). I figure I might as well explain the point of all this anyways: I'm going to be having as data a large number of RGB values, and am trying to plot them all in a 3d cubic space, so one can visually see clustering of the colors. For now I'll try gnuplot some more, but any other suggestions would be great. Thanks.
      Ok first I want to apoligize for my previous post ... the formulas are fscked up. Rather than try to fix them for the general case Ill give you a simple version that will work for your specific case.
      for each point R,G,B contained in (0,1)x(0,1)x(0,1):
      X=(R-0.5)/(B+1)*IMAGE_WIDTH  + IMAGE_WIDTH/2
      Y=(G-0.5)/(B+1)*IMAGE_HEIGHT + IMAGE_HEIGHT/2
      You can change the 1 to 'dolly' the camera back and forth. Just swap the variables to view along a different color axis.
      To view not along a color axis you need to rotate the points before hand. eg
      R'= R*cos(theta)+G*sin(theta)
      B'= B
      to rotate about the B axis
      R'= R
      G'= G*cos(theta)+B*sin(theta)
      to rotate about the R axis, and
      to rotate about the G axis

      Geez I can't get anything right...maybe this really isnt as simple as I said :). The formulas should now map the entire RGB space into the image ... if you rotate the space then the corners will not be visible ... fix this by increasing the value added to the denomiator.
        Thank you very much for all this; I'll get to experimenting with it after exams are over, and most likely post what happens. (and the name, it's still me, I just decided to register)

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (10)
As of 2023-02-07 17:47 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (40 votes). Check out past polls.