POV-Ray : Newsgroups : povray.advanced-users : matrix help.... : Re: matrix help.... Server Time
29 Jul 2024 22:23:15 EDT (-0400)
  Re: matrix help....  
From: David Fontaine
Date: 8 Sep 2000 20:49:28
Message: <39B98800.6B41C439@faricy.net>
Margus Ramst wrote:

> The Reorient macro should do exactly what you need, and there should be no need
> to understand the inner workings of the matrix command. Doesn't it work for you,
> and if so, why?

John's macro should do what you want. The only problem I think would be the axial
rotation changing, but if your gun stays pointing on the x-z plane with y up it
shouldn't matter I think. I've written one aimilar to keep axial rotation the same
(perpendicular vector intersecting y axis still intersects y axis). It's a lot
messier than John's though.
Scales according to vector length ratios, comment out scale if u don't want it.

#macro reposition(vec1,vec2)
   #if (vlength(vec1)=0)
      #render "Warning: reposition 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
   scale vlength(vec2)/vlength(vec1)
   #if (vlength(vec2)=0)
      #render "Warning: reposition 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


--
David Fontaine   <dav### [at] faricynet>   ICQ 55354965
Please visit my website:  http://davidf.faricy.net/


Post a reply to this message

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