POV-Ray : Newsgroups : povray.advanced-users : matrix help.... : Re: matrix help.... Server Time
29 Jul 2024 22:20:23 EDT (-0400)
  Re: matrix help....  
From: Tor Olav Kristensen
Date: 14 Sep 2000 14:08:38
Message: <39C112CD.E7CDF57D@online.no>
J Charter wrote:

> Yikes! This is great!  So I put together concepts from Margus and David and come up
> with the following.  And it seems to solve a problem I've been chasing for some
> time,...how to orient an arbitrary set of points from a shape ( the processes of a
> vertabrae ) along a spline ( forming the axial structure of an animal's turning neck
)
> and know what the new point locations are ( in order to attach muscles at their
> insertion points ).  Mild testing seems to indicate this works!  Can anyone who
knows
> vet this?  Is this really a solution?  Is there a cleaner way?
>
> #macro repoint(pt,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;
>
>    #local pt = vrotate ( pt, <0,-RotY,0>    )
>    #local pt = vrotate ( pt, <RotX,0,0>     )
>
> ... 8< Snip ...

May I suggest using degrees() instead of
multiplying with 180/pi ?
E.g.: RotY=degrees(atan2(vec1.x,vec1.z));

You can also write asin(vnormalize(vec1).y)
instead of asin((vec1.y)/vlength(vec1))


Tor Olav
--
mailto:tor### [at] hotmailcom
http://www.crosswinds.net/~tok/tokrays.html


Post a reply to this message

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