POV-Ray : Newsgroups : povray.advanced-users : Inverse Kinematics : Re: Inverse Kinematics Server Time
29 Jul 2024 00:31:28 EDT (-0400)
  Re: Inverse Kinematics  
From: Patrick Elliott
Date: 21 Jul 2003 16:03:01
Message: <MPG.1985f4069895ed27989840@news.povray.org>
In article <3f1bbad4@news.povray.org>, dar### [at] earthlinknet says...
> 
> "Patrick Elliott" <sha### [at] hotmailcom> wrote in message
> news:MPG.19836835a2284e4b98983c@news.povray.org...
> > In article <3f192104$1@news.povray.org>, tim### [at] gmxde says...
> > > It does sound interesting, but also a little above
> > > my head at the moment... Nontheless, thanks
> > > for link, perhaps I can make something of it when
> > > having more time to spend on it...
> > >
> >
> > Simplest definition is that Inverse Kinematics uses some sort of nesting
> > of objects. In SDL this is easy:
> >
> > union {
> >   Object1
> >   Object {
> >     Object2
> >     rotate <x2,y2,z2>
> >   }
> >   rotate <x1,y1,z1>
> > }
> >
> An array-based approach works too.
> 
> #declare ataObjs = array[8] { ataBase, ataSectB, ataSectM, ataSectM,
> ataSectM, ataSectH, ataHandL, ataHandR }
> #declare ataLens = array[8] { atabHgtB, atasH, atasH, atasH, atasH, atasH,
> 0, 0 }
> #declare atArmAng = array[1][3]
> #declare atArmAng[0][0] = array[7] { <-40, 20,-35>, x*26, x*30 , x*28, x*33,
> x* 5,-x*10 }
> #declare atArmAng[0][1] = array[7] { < 10, 70,  5>, x* 6, x* 4 , x* 8, x*13,
> x*10,-x*20 }
> #declare atArmAng[0][2] = array[7] { <- 3,-90,-15>, x*10, x* 8 , x*14, x*11,
> x*15,-x*30 }
> #declare ataMoves = array[7]
> 
> #macro ManipArm(Objects, Lengths, Joints, Moves)
>  #local aSiz = dimension_size(Joints,1);
>  #debug concat(str(aSiz,0,0), " objects.\n")
>  #local ps = 0;
>  #while (ps<aSiz)
>   #local rt = ps;
>   #declare Moves[ps] = transform {
>    #while (rt>=0)
>     rotate Joints[rt]
>     translate y*Lengths[rt]
>     #local rt = rt - 1;
>    #end
>   }
>   #local ps = ps + 1;
>  #end
>  union {
>   #set ps = 0;
>   object { Objects[ps] }
>   #while (ps<aSiz)
>    #local ps = ps + 1;
>    object { Objects[ps] transform { Moves[ps-1] } }
>   #end
>  }
> #end
> 
> #macro atArm(obn, arn) object { ManipArm(ataObjs, ataLens,
> atArmAng[obn][arn], ataMoves) } #end
> 
> The idea is to set up the transforms for each object first so that nesting
> becomes unnecessary:
> 
> If you want the object definitions check out my "Manipulator arm" thread.
> 

Yes, such an approach 'is' possible, but far more complex, especially for 
very complex mechanisms. Nesting has the advantage of providing a clear 
structure for the objects relationships within the SDL code itself. You 
can see immediately where you screwed something up by incorrectly nesting 
it. Using an array system requires, for one thing keeping track of the 
current position of 'both' ends, since sub objects do not automatically 
move to match to position and location of their parent in such a system. 
It isn't something I would attempt to make adjustments to by hand. ;)

-- 
void main () {

    call functional_code()
  else
    call crash_windows();
}


Post a reply to this message

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