POV-Ray : Newsgroups : povray.binaries.animations : Organic motion: when as much as where Server Time
1 Nov 2024 19:13:55 EDT (-0400)
  Organic motion: when as much as where (Message 1 to 10 of 10)  
From: Greg M  Johnson
Subject: Organic motion: when as much as where
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)

From: Kitsune e
Subject: Re: Organic motion: when as much as where
Date: 23 Apr 2003 23:25:05
Message: <web.3ea7582cdc91ff0e7a3893e20@news.povray.org>
Greg M. Johnson wrote:
>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.
>

Good animation! I especially like the lighted path.  About the motion: it
does give a nice organic feel, though it might work better with slightly
rounded paths.

I don't know the specifics of your system, but I wonder if you couldn't just
use a spline.  With a spline the float value would corispond to a place in
time, and then you have <x,y,z> deffined for any time you ask for.  Being
able to pass a spline as a parameter to your IK system would be pretty
slick!


Post a reply to this message

From: Remco de Korte
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 08:31:55
Message: <3EA7D90C.51376DFA@onwijs.com>
"Greg M. Johnson" wrote:
> 
> 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.
> 

Interesting. Is this the prescribed formula? I'll take your word for it,
but otherwise it might be interesting to experiment a bit with some
alternatives. I guess I would have immediately come up with some
sine-wave-thingie (as always).

Remco


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 11:29:43
Message: <3ea802e7$1@news.povray.org>
"Kitsune_e" <kit### [at] hotmailcom> wrote in message
news:web.3ea7582cdc91ff0e7a3893e20@news.povray.org...

>
> I don't know the specifics of your system, but I wonder if you
> couldn't just use a spline.

Povray 3.5 does not have any way to determine the number of elements or
points in a previously defined spline. This would be necessary for such a
solution. Apparently MegaPov 1.0 does have such a utility.  Thus, I'm forced
to use a four-dimension array.

> About the motion: it does give a nice organic feel, though it might
> work better with slightly rounded paths.

When you're jogging, the position of your hands are likely sine function
based. This application, however, is for the position of the hands.  In a
conversation, working in the kitchen, or just sitting at a desk, I'd guess
hands tend to move to places in more of a straight line.   But there's the
acceleration in and out that isn't realistically related by a spline,
whether natural or linear.   I suppose one could have both this ease in &
out and a natural spline for the position of the points, but that makes my
head spin right now.


Post a reply to this message

From: ABX
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 11:37:18
Message: <sp0gav0vbnq3ije0h8g0dmtnb2m95q4dgf@4ax.com>
On Thu, 24 Apr 2003 11:29:04 -0400, "Greg M. Johnson" <gregj:-)565### [at] aolcom>
wrote:
> Povray 3.5 does not have any way to determine the number of elements or
> points in a previously defined spline. This would be necessary for such a
> solution. Apparently MegaPov 1.0 does have such a utility.

But you can always define structure which can be used to maintain many different
data in one place and put that structure into macros for operations.
http://news.povray.org/6lpkut0vdh0h6gljr7u2v4mip6olddkmel%404ax.com
So you can still have predefined spline and number of entries stored in one
structure available for usage in pure 3.5 SDL.

ABX


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 12:12:42
Message: <3ea80cfa$1@news.povray.org>
Fascinating.  The curves

3*x^2-2*x^3
and
0.5*(1-cos(x*pi))

practically lie on top of each other and have the same derivative.  I guess
that the sines are expressable as infinite series, but it's funny how it
worked out.

"Remco de Korte" <rem### [at] onwijscom> wrote in message
news:3EA7D90C.51376DFA@onwijs.com...
>
> Interesting. Is this the prescribed formula? I'll take your word for it,
> but otherwise it might be interesting to experiment a bit with some
> alternatives. I guess I would have immediately come up with some
> sine-wave-thingie (as always).
>
> Remco


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 13:28:26
Message: <3ea81eba$1@news.povray.org>
I appreciate what you've suggested, but don't understand it well enough to
see the value-add of implementing it.

"ABX" <abx### [at] abxartpl> wrote in message
news:sp0gav0vbnq3ije0h8g0dmtnb2m95q4dgf@4ax.com...
> On Thu, 24 Apr 2003 11:29:04 -0400, "Greg M. Johnson"
<gregj:-)565### [at] aolcom>
> wrote:
> > Povray 3.5 does not have any way to determine the number of elements or
> > points in a previously defined spline. This would be necessary for such
a
> > solution. Apparently MegaPov 1.0 does have such a utility.
>
> But you can always define structure which can be used to maintain many
different
> data in one place and put that structure into macros for operations.
> http://news.povray.org/6lpkut0vdh0h6gljr7u2v4mip6olddkmel%404ax.com
> So you can still have predefined spline and number of entries stored in
one
> structure available for usage in pure 3.5 SDL.
>
> ABX


Post a reply to this message

From: Slime
Subject: Re: Organic motion: when as much as where
Date: 24 Apr 2003 15:03:22
Message: <3ea834fa@news.povray.org>
> 3*x^2-2*x^3
> and
> 0.5*(1-cos(x*pi))
>
> practically lie on top of each other and have the same derivative.  I
guess
> that the sines are expressable as infinite series, but it's funny how it
> worked out.

Yeah, those are two extremely useful functions. The differences start coming
into play when you take the second derivative, I think.

Generally, I prefer the latter of the two, but I use the former in any case
where speed matters, since it can be calculated quickly by a computer when
written as:

x*x*(3-2*x)

This function is actually used in the POV-Ray source code to smooth out the
noise generator functions (bozo).

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: ABX
Subject: Re: Organic motion: when as much as where
Date: 25 Apr 2003 04:06:24
Message: <32phavgaltnhrqbvll39m2rcaifg6birqr@4ax.com>
On Thu, 24 Apr 2003 13:27:46 -0400, "Greg M. Johnson" <gregj:-)565### [at] aolcom>
wrote:
> I appreciate what you've suggested, but don't understand it well enough to
> see the value-add of implementing it.

I made implementation for you. For sure it needs customization to your project
but I hope it could make your operations simpler.

http://news.povray.org/1eqhavcliagj5dthfpf7d2o68nklhqju3u%404ax.com

ABX


Post a reply to this message

From: Kitsune e
Subject: Re: Organic motion: when as much as where
Date: 1 May 2003 22:30:05
Message: <web.3eb1d773dc91ff0e80837b940@news.povray.org>
ABX wrote:
>On Thu, 24 Apr 2003 13:27:46 -0400, "Greg M. Johnson" <gregj:-)565### [at] aolcom>
>wrote:
>> I appreciate what you've suggested, but don't understand it well enough to
>> see the value-add of implementing it.
>
>I made implementation for you. For sure it needs customization to your project
>but I hope it could make your operations simpler.
>
>http://news.povray.org/1eqhavcliagj5dthfpf7d2o68nklhqju3u%404ax.com
>
>ABX
>

Wow, that data Struct is very neat (followed the links).  I think I could
come up with some uses for that...


Post a reply to this message

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