The POV-Ray Cyclopedia

Bill DeWitt (bdewitt@gateway.net) asked for more information about vrotate and other vector expressions.

The advantages of using vrotate? By keeping the vector in a variable, you can get the actual value of the vector. I find this so useful that I made a simple macro and loaded it in my standard include files:
#macro ReportV(size)
  #render concat("\nReported Vector is <" + str(size.x,3,3) + "," +
          str(size.y,3,3) + "," + str(size.z,3,3) + ">" )
#end
For a more specific application: elliptical planetary orbit. Lets make a model planet rotate along it's axis.

**** COMING SOON ****

play ground Step 1
Creating the scene
Here is the scene we are going to work with. The red sphere sits on the floor. Here is the code to set this scene up:
light_source { <0,0,-1000> color rgb 1 
               rotate <45,30,0> }

plane { y,-0.25 pigment { checker color rgb 0.9 color rgb 0.5 } }

#declare rv = <115,165,-65>;

#declare p1 = <1,0,-1>;

sphere { p1,0.25 pigment { red 1 } finish { phong 1 } }
rv is our rotation vector, and p1 is the position of the sphere.
Step 2
Rotate around the x axis
Vrotate works exactly the same as the rotate command, it only applies to vectors where rotate applies to objects. Like any rotation this is done by rotating around the x axis first. Note that the two code blocks below place the sphere in the same place... the texture would be applied differently:
// BLOCK ONE
#declare p2 = vrotate(p1,<rv.x,0,0>);
sphere { p2, 0.25 pigment { red 1 } finish { phong 1 } }

// BLOCK TWO 
sphere { p1, 0.25 pigment { red 1 } finish { phong 1 } 
         rotate <rv.x,0,0> }
Below is an example of this in a bit more detail. The red curve shows the full range of rotation for the sphere.
Step 3
Rotate around the y axis
Next, we rotate around tht y axis...
#declare p3 = vrotate(p1,<rv.x,rv.y,0>);
sphere { p3, 0.25 pigment { red 1 } finish { phong 1 } }
and this time the green curve indicates this rotation.
Step 4
Rotate around the z axis
And finally we rotate around the z axis. Normally you probably wont need to (or want to) rotate around all three axes. Two will suffice.
#declare p4 = vrotate(p1,<rv.x,rv.y,rv.z>);
sphere { p4, 0.25 pigment { red 1 } finish { phong 1 } }
And (need we say it?) the blue curve shows the rotation around the z axis.
Send feedback, or head back to the Cyclopedia.

Thanks for watching.


View my guestbook
Sign my guestbook