Site hosted by Angelfire.com: Build your free website today!

Rotation of Objects

tudor3ss.jpg (84999 bytes) The spell spinning over the pentagram and cauldron in the middle of the scene is created by a variety of rotations.  The major rotation is the cards spinning in a donut space around the center effect.  Several variables are needed to obtain this positioning

The second rotation is the haphazard rotation of the cards.  They are all rotated randomly around all three axis before being moved into their final positions.

Code to accomplish this effect looks like this:

#declare RS=seed(588);     // establish a seed
#declare C1=1;             // initialize a counter
#while (C1<=NC)            // NC=number of cards
 #declare ROX=rand(RS)*360;    // X rotation for the card
 #declare ROY=rand(RS)*360;    // Y rotation for the card
 #declare ROY2=rand(RS)*360;   // Y rotation for the card's final position
 #declare ROZ=rand(RS)*360;    // Z rotation for the card
 #declare ROD=rand(RS)*2.5+.5; // How far out the card is from <0,0,0>
 #declare ROH=rand(RS)*.25+1;  // How high up the card should move
 object{
   <select a card>             // <--- somehow select your card
 rotate<ROX,ROY,ROZ>           // this rotates the card on all three axis
 translate<0,ROH,ROD>          // move the card out and up
 rotate<0,ROY2,0>              //  rotate the card around the Y axis
 }
 #declare C1=C1+1;             // do the next card
#end                    // of while loop
Rotation is used to build the room as well.  The columns, windows, and roof bracing are all rotated into their final positions.  Unlike the spell rotations, these objects are kept in the same orientation that they had before being moved.

Code to accomplish this looks like the following:

(Window1, Col1, WoodTruss and ArchTop are all defined ahead of this code)

#declare TWW=7;      // The radius of the space
#declare C1=15;          // start at 15 degree point
#while (C1<=335)      //  end at -15 degree point  to leave gap for fireplace
object{Window1 translate<0,3.4,TWW-.2> rotate<0,C1+5,0>} 
object{Col1 translate<0,0,TWW-.5> rotate<0,C1,0>}
object{WoodTruss translate<0,3.2,TWW-.65> rotate<0,C1,0>}
object{ArchTop translate<0,3.3,TWW-.61> rotate<0,C1+5,0>}
#declare C1=C1+10;  // rotate to next 10 degree point
#end
// add odd set at end, these fill in the 30 degree's skipped above
object{Col1 translate<0,0,TWW-.5> rotate<0,345,0>}
object{WoodTruss translate<0,3.2,TWW-.65> rotate<0,345,0>} 
object{WoodTruss translate<0,3.2,TWW-.65> rotate<0,355,0>} // fireplace truss 1
object{WoodTruss translate<0,3.2,TWW-.65> rotate<0,5,0>} // fireplace truss 2 
tudor4ss.jpg (99029 bytes)
pentagram.jpg (36887 bytes) The pentagram owes its creation to the same rotation used in the other creations.  What has to be computed is based on the number of  vertexes the final star has to have.  Two angles are critical.  The pentagram is constructed from a "V" placed and rotated to create the 5 pointed star.  Some legs of the "V" overlap others, this is fine for the finished product.

360 divided by 5 gives us a rotation factor of 72 degrees.  The "V" angle is exactly 1/2 of that or 36.

The code for this is as follows:

// Declare "V" portion
#declare Penta1=union{
  box{<-.1,0,-3><.1,0.001,0> rotate<0,18,0> translate<0,0,1.5>}
  box{<-.1,0,-3><.1,0.001,0> rotate<0,-18,0> translate<0,0,1.5>}
} 
// The outside cylinders
#declare Rim=union{
  difference{
    cylinder{<0,0,0><0,.001,0> 1.7}
    cylinder{<0,-.1,0><0,.002,0> 1.5} 
  }
  difference{
    cylinder{<0,0,0><0,.001,0> 1.75}
    cylinder{<0,-.1,0><0,.002,0> 1.7}
   texture{T_Stone21 scale .25}
  }
  difference{
    cylinder{<0,0,0><0,.001,0> 1.5}
    cylinder{<0,-.1,0><0,.002,0> 1.45}
   texture{T_Stone21 scale .25}
  } 
} 
// Put it all together
#declare Pentagram=union{
  object{Penta1 rotate<0,0,0>}
  object{Penta1 rotate<0,-72,0>}
  object{Penta1 rotate<0,-144,0>}
  object{Rim} 
 texture{T_Stone18 scale .25}
}

© 2000, Robert J Becraft, All Rights Reserved.