PVector Heading() for 3D Coordinates

Hi,

I want to use the heading() function in the PVector class, but I am using P3D and have an x,y,and z for my PVector. How would I re-write this function to allow it to work for 3D space? My goal is to do something like:

      size(100, 100, P3D);
      PVector v = new PVector(.2, .11, .54);
      rotate( v.heading() ); //set rotation from PVector named v
      line(0, 0, 10, 0); //draw line that will be rotated in correct direction

The above code doesn't display the correct rotation in 3D space since v.heading() is only suited for 2D coordinate space. How can I achieve this using rotateX(), rotateY(), rotateZ()? I'd like to avoid using a quaternion if possible and use the rotate functions.

Thanks in advance!!

Sign In or Register to comment.