POV-Ray : Newsgroups : povray.animations : Help! Angles or Targets? : Re: Help! Angles or Targets? Server Time
6 Oct 2024 11:12:18 EDT (-0400)
  Re: Help! Angles or Targets?  
From: Josh English
Date: 31 Jan 2002 16:41:37
Message: <3C59B9EA.5C33F273@spiritone.com>
John Van Sickle has a findknee macro on his page, and I use that to
create fingers. I have to double up on the macro. If you play with this
code you may find it helpful.


// From JVS's site 
#macro FindKnee(pA,pH,lT,lS,vD)
  #local lB=vlength(pA-(pH));
#if( (lB>lT+lS) | (lT>lB+lS) | (lS>lT+lB) )
#error "Invalid span lengths.\n"
#end
  #local tX=(lT*lT-lS*lS+lB*lB)/2/lB;
  #local tY=sqrt(lT*lT-tX*tX);
  #local vO=vnormalize(pA-(pH));
  #local vF=vnormalize(vcross(vD,vO));
  #local vU=vnormalize(vcross(vO,vF));
  (pH+vO*tX+vU*tY)
#end

#declare l0 = 1; // Length of one flange
#declare l1 = 0.75; // Length of second flange
#declare l2 = pow(0.75,2); // COrrected length (if memory serves)
#declare p0 = <-0.75,0.25,0>; // The Base of the finger
#declare p1 = <0.25,0,0>;
#declare p2 = <0.5,-1,0>;
#declare px = p2 + (p1 - p2)*SmoothEnds(Five(clock)); 

// px is the target. The smoothends macro was one I made to simulate a
finger tapping.
// Use what you will for px

sphere { p0 0.1 pigment { rgb 1 } }
sphere { px 0.1 pigment { rgb 1 } }

#declare j1 = FindKnee(px,p0,l0,(l1+l2)*0.9,x);
#declare j2 = FindKnee(px,j1,l1,l2,(j1-p0));
sphere { j1 0.1 pigment { rgb 1 } }
sphere { j2 0.1 pigment { rgb 1 } }
cylinder { p0 j1 0.1 pigment { rgb 1 } }
cylinder { j1 j2 0.1 pigment { rgb 1 } }
cylinder { j2 px 0.1 pigment { rgb 1 } }

Hope this helps.

Josh English
eng### [at] spiritonecom
http://www.spiritone.com/~english


Post a reply to this message

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