|
|
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
|
|