POV-Ray : Newsgroups : povray.binaries.animations : Organic motion: when as much as where : Organic motion: when as much as where Server Time
19 Jul 2024 07:24:03 EDT (-0400)
  Organic motion: when as much as where  
From: Greg M  Johnson
Date: 23 Apr 2003 22:03:45
Message: <3ea74601@news.povray.org>
I've read in some animation books about the importance of easing in and out.
So I wrote an algorithm where the position is along striaght lines, but
moves as per 3*x^2-2*x^3 between the points.   I think I'm going to start
using it in my animations, and thought I'd share it in case it's of value to
anyone else.



// Povray 3.5 Scene description file

//your sample array

#declare ary=array[4]{
//an array of four dimensions:
//< time,  x_position[n], y_position[n], z_position[n]>

<0.00,     -1,1,0>,
<0.35,  -2,-0.5,0>,
<0.67232,   0,0,0>,
<1.02341230,-1,1,0>
}



#macro ease_in(your_clock,your_array)

        #local rotdim=dimension_size(your_array,1);
        #local ennn=0;
        #while(ennn<rotdim)


                #if(your_array[ennn].x=your_clock)

                        <
your_array[ennn].y,your_array[ennn].z,your_array[ennn].t>

                        #declare ennn=ennn+1e7;

                #else

                        #if(your_array[ennn].x<your_clock)

                                #local ennn=ennn+1;

                        #else
                                #local why1=your_array[ennn+0];
                                #local why0=your_array[ennn-1];

                                #local
teee=(your_clock-why0.x)/(why1.x-why0.x);
                                #local
teeecubes=3*pow(teee,2)-2*pow(teee,3);

                                #local
exxx=why0.y+(why1.y-why0.y)*teeecubes;
                                #local
eyyy=why0.z+(why1.z-why0.z)*teeecubes;
                                #local
ezzz=why0.t+(why1.t-why0.t)*teeecubes;

                                #declare ennn=ennn+1e7;
                                <exxx,eyyy,ezzz>

                        #end
                #end
        #end

#end



//algorithm for display of points along uniform time increments.
#declare n=0;
#while(n<100)
        sphere{ ease_in(n/100,ary), 0.02 pigment {red 1 green 0.5}
finish{ambient 1} }
#declare n=n+1;
#end



// who made this macro, I dunno. Was it Rune or JvS?
#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"
        #declare gk=1/0/0/0/0/0/0/0/0;
#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


//complicated example showing use of
// the easein macro for determination of wrist point

#declare bodytexture=texture{pigment{rgb 0.7} finish{ambient 0.2 metallic
phong 0.5} normal{facets scale 0.15}}

#declare shoulderpoint=<2,0.5,0>;
#declare wristpoint=(ease_in(clock,ary));
#declare elbowpoint=FindKnee(wristpoint,shoulderpoint,2.5,2.5,-y);

#declare n=0;
#while(n<5)
        cylinder {0,<1,1,0>/2,0.05 rotate y*(90+180*n/5) translate
wristpoint texture{bodytexture}}
        sphere {<1,1,0>/2,0.05 rotate y*(90+180*n/5) translate wristpoint
texture{bodytexture}}
        cylinder {<1,1,0>/2,<0.75,2,0>/2,0.05 rotate y*(90+180*n/5)
translate wristpoint texture{bodytexture}}
        sphere {<0.75,2,0>/2,0.05 rotate y*(90+180*n/5) translate wristpoint
texture{bodytexture}}
#declare n=n+1;
#end


sphere{shoulderpoint, 0.2 texture{bodytexture}}
cylinder{shoulderpoint,elbowpoint, 0.1 texture{bodytexture}}
sphere{elbowpoint, 0.2 texture{bodytexture}}
cylinder{elbowpoint,wristpoint,0.1 texture{bodytexture}}
sphere{wristpoint, 0.2 texture{bodytexture}}

light_source{<-0,100,-20> color rgb <1.7,1,0.5>}
light_source{<10,-10,-60> color blue 0.5}
camera{location <0,0,-5>}


Post a reply to this message


Attachments:
Download 'easein0901c.mpg' (293 KB)

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