prev index next 
Modelling Tips, Working With Primitives 
 POV-Ray Tips, 
 Tricks, and Techniques
Rotation: Aligning an Object Along a Given Vector? 
 
Matthew W Buckley is getting desperate: Does anyone know what combination of the POV-Ray vector functions I should use to rotate something which is aligned along the y axis so that it ends up aligned along a given vector? 

I really need this, so any advice is appreciated. 
 

Chris Colefax is just in time:
I recently had a similar problem, so here is one solution: 

  #declare OldVector = <0, 10, 0> 
  #declare DirVector = <3.5, -5, 10> 
  #declare NewVector = vrotate (OldVector, 
   <degrees (atan2 (vlength (DirVector * <1, 0, 1>), DirVector.y)), 
    degrees (atan2 (DirVector.x, DirVector.z))>) 

This works by first tilting the original vector around the x-axis to 
reach the right angle, then spinning the resultant vector around the y-axis to move it into the final position.  This gives a vector of the same length as the OldVector, parallel to the DirVector. 

I don't know if this is the easiest or best way to accomplish this, but it should work (I hope!). 
 

  1