POV-Ray : Newsgroups : povray.advanced-users : look_at for objects? : Re: look_at for objects? Server Time
30 Jul 2024 04:14:58 EDT (-0400)
  Re: look_at for objects?  
From: David Fontaine
Date: 16 Mar 2000 17:12:05
Message: <38D15B46.4CEFD082@faricy.net>
Yes!
// Reorient from <0,0,1> to p
#macro PointTo(p)
   #if (0+p.x=0 & 0+p.y=0 & 0+p.z=0)
      #local RotX=0;
   #else
      #local RotX=-atan2(p.y,sqrt(pow(p.x,2)+pow(p.z,2)))*180/pi;
   #end
   #if (0+p.x=0 & 0+p.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(p.x,p.z)*180/pi;
   #end
   rotate <RotX,RotY,0>
#end

or

//reorient from vector 1 to vector 2
#macro reposition2(vec1,vec2)
   #if (vlength(vec1)=0)
      #render "Warning: reposition2 initial vector length is zero.\n"
   #end
   #if (vec1.x=0 & vec1.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(vec1.x,vec1.z)*180/pi;
   #end
   #local RotX=asin((vec1.y)/vlength(vec1))*180/pi;
   rotate -RotY*y
   rotate RotX*x
   #if (vlength(vec2)=0)
      #render "Warning: reposition2 final vector length is zero.\n"
   #end
   #if (vec2.x=0 & vec2.z=0)
      #local RotY=0;
   #else
      #local RotY=atan2(vec2.x,vec2.z)*180/pi;
   #end
   #local RotX=asin((vec2.y)/vlength(vec2))*180/pi;
   rotate <-RotX,RotY,0>
#end

--
___     _______________________________________________
 | \     |_          <dav### [at] faricynet> <ICQ 55354965>
 |_/avid |ontaine        http://www.faricy.net/~davidf/

"The only difference between me and a madman is that I'm not mad." -Dali


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.