POV-Ray : Newsgroups : povray.general : Find angle Server Time
9 Aug 2024 15:19:49 EDT (-0400)
  Find angle (Message 1 to 2 of 2)  
From: Greg M  Johnson
Subject: Find angle
Date: 6 Jul 2000 14:43:16
Message: <3964D221.DD54F843@my-dejanews.com>
I set up a body with FK, in that the arms and legs move via rotations
about their joints.  After seeing Rune describe his animatable
character,  I now want to make mine IK, where I would call out a
position of the wrist and ankle, and have these ROTATIONS internally
calculated.

JvS'    FindKnee(Ankle,Hip,Thigh,Shin,Direction) macro appears to be
very useful, although not for my application. Or at least I'm not
conceiving of an immediate application. I want the rotation of joints,
not the knee point.


Post a reply to this message

From: Rune
Subject: Re: Find angle
Date: 6 Jul 2000 17:42:27
Message: <3964fd43@news.povray.org>
"Greg M. Johnson" wrote:
> I set up a body with FK, in that the arms and legs move via rotations
> about their joints.  After seeing Rune describe his animatable
> character,  I now want to make mine IK, where I would call out a
> position of the wrist and ankle, and have these ROTATIONS internally
> calculated.
>
> JvS'    FindKnee(Ankle,Hip,Thigh,Shin,Direction) macro appears to be
> very useful, although not for my application. Or at least I'm not
> conceiving of an immediate application. I want the rotation of joints,
> not the knee point.

So you want to control you character with IK, then convert the IK data to
FK, so that the code can "understand" it?

Interesting. I have thought of similar things, but personally prefer the
direct method. However, in your case the method you're describing is the
only one that doesn't require a total rewrite of your character.

From the information I've got I can't help you much, but maybe the following
macros might be helpful in your work.

Using the Knee macro you described you have for your disposal both the
location of the hip, the knee, and the ankle. Having got these, you can,
depending on the situation, use either one or another of the macros bow to
find the rotate angles you need. If you need more help, feel free to ask.
:-)

// Perpendiculize will adjust the vector V1
// so that it is perpendicular to the vector V2.
// The input is V1 and V2, and the macro returns
// the adjusted version of V1.
#macro Perpendiculize (V1,V2) // by Rune S. Johansen
   vnormalize(vcross(vcross(V2,V1),V2))
#end

// FindAngle will find the angle between V1 and V2.
// The third parameter "About" is a vector which must be
// perpendicular to both V1 and V2. If the rotation from
// V1 to V2 about "About" is negative, the returned angle
// is negative. ( When you look in the direction of "About"
// clockwise is negative and anticlockwise is positive. )
// If you set "about" to <0,0,0> the returned angle will
// always be positive (or zero).
#macro FindAngle (V1,V2,About)
   degrees(acos(vdot(vnormalize(V1),vnormalize(V2))))
   *(vdot(About,vcross(V1,V2))<0?-1:1)
#end

// Given 2 vectors, a vector for the X direction
// (similar to the 1st - 3rd number in a matrix),
// and one for the Y direction (similar to the
// 4th - 6th number in a matrix), Vectors2Rotate will
// return a rotation vector which will transform an
// object in the same way as a matrix using the
// vectors would do. VectorX and VectorY must be
// perpendicular to each other.
#macro Vectors2Rotate (VectorX,VectorY) // by Rune S. Johansen
   #local RotZ = FindAngle(x,<VectorX.x,VectorX.y,0>,z);
   #local RotY = FindAngle(x,vrotate(VectorX,-RotZ*z),y);
   #local RotX = FindAngle(vrotate(y,<0,RotY,RotZ>),VectorY,VectorX);
   <RotX,RotY,RotZ>
#end

Greetings,

Rune
--
Updated June 12: http://rsj.mobilixnet.dk
3D images, include files, stereograms, tutorials,
The POV Desktop Theme, The POV-Ray Logo Contest,
music, 350+ raytracing jokes, and much more!


Post a reply to this message

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