POV-Ray : Newsgroups : povray.advanced-users : Math help needed please. : Re: Math help needed please. Server Time
30 Jul 2024 20:29:53 EDT (-0400)
  Re: Math help needed please.  
From: Josh English
Date: 19 Apr 1999 13:33:46
Message: <371B5AB6.70BF3BFF@spiritone.com>
errrmmmmmm...... It won't work. let me explain.  Asphere with a radius of 1 has a
circumference of  2pi (roughly 6.2831 something something something). To model this
realistically, if the sphere were to rotate clockwise around the z axis one whole
revolution
then the appropriate movement along the x axis would be 2pi units long. Half the
rotation of
the ball is pi across the x axis (3.14159 and change). Moving only 1 unit would result
in the
ball spinning faster than it was moving. Fine for cue balls and Fred Flintstone (ever
notice
how his feet slide across the ground when he's walking?)

It sounds like the placement of the sphere is more important than how much it rotates,
so we
need to alter the amount of rotation. Keeping a ratio of 180/pi, where pi is the
distance
traveled and 180 is the rotation, we can create a formula or x/1 = 180/pi. x is the
rotation
needed to move 1 unit, and it is baiscally 57.295 plus a little extra. (At this point
I am
very grateuful that POV-Ray has pi as a built in value, thus saving lots of
calculations.)

Here is some code to generalize the movement:

#declare start_point = -0.5;
#declare end_point = 0.5;

#declare distance = end_point - start_point; // should be 1 in this example

#declare start_rotation = 0;
#declare end_rotation = distance*(180/pi);
#declare range = end_rotation - start_rotation;

// Now assume that the clock is going from 0 to 1, if it isn't the appropriate
formulas are at

// http://www.spiritone.com/~english/animaker/animaker.html

#declare current_rotation = start_rotation + (range * clock);
#declare current_translation = start_point + (distance * clock);
sphere { <0,0,0> 1
                texture { MyTexture }
                rotate current_rotation*z
                translate current_translation * x
             }

plane { y, -1
             texture { MyOtherTexture } }


This covers the basics... altering the shape of the thing is slightly more complicated
to
calculate... but I'll look into it.

Josh English
eng### [at] spiritonecom



Andrew Cocker wrote:

> Hi,
>
> Starting with the following code:
>
> sphere {
>     <0,0,0>,1
>     scale <0.25,1,0.25>
>     translate <-0.5,0,0>
>     texture { MyTexture }
> }
>
> plane
>
>     y, -1
>     texture { MyTexture }
> }
>
> I wish to rotate the sphere clockwise on the z axis by 180 degrees, at the same time
> translating it along the x axis by 1 unit, so that it ends up at <0.5,0,0>.
> The question is, how do I mathematically model the vertical motion so that the shape
> appears to be rolling along the plane?NOTE: I may wish to alter the scale of the
shape
> *during* the anim, so this must be taken into account in the equation.
>
> Any help appreciated.
>
> --
> ----------------------
> Andy
>
------------------------------------------------------------------------------------------
> -
> --The Home Of Lunaland--
> --visit my POV-Ray gallery--
> --listen to my music--
> www.acocker.freeserve.co.uk


Post a reply to this message

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