First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
Search tutorials
Author: Michele Microon | Website: http://www.microon.com

Mathematical functions

What it determines the new value of rotation that our pendulum will have on every instant - i.e. frame - it is the associated mathematical function. It is well know that the function sine has an oscillating course, but constant in the time, and that it oscillates between values +1 and -1; therefore if we associate the simple function sine to the rotation of the pendulum, where the rotation value is given instant to instant - frame to frame - from the value that assumes sin(a) (a is our quarter variable, that it increases to every frame), the pendulum will oscillate between +1 degree and -1 degree, too much little for being appreciated visually:

this is the reason for which we use the variable maxang: it works as multiplier of sin(a); if sin(a) oscillates between +1 and -1, and we give maxang to a value of 60, then

maxang*sin(a)

it will oscillate between +60 (degrees) and -60 (degrees).

Notes: according to ActionScript syntax it must write maxang*(Math.sin(a))

Now we want that the pendulum does not oscillate forever, but that it stops its movement, gradually. In order to realize this, we need a function that multiplied to "maxangle*sin(a)", at the beginning it does not have influence but with passing of the time reduces the oscillation until 0 (that is pendulum stopped). Moreover this function must have an effect that carry gradually to 0: the perfect function for this result is just the power function, that is

n^a

where n it is a real number >0. It is well know that the function power has these property:

 

  • if n>1 it has increasing graph;
  • if 0<n<1 it has decreasing graph, and if a is "much large" the function catches up the 0 (and therefore multiplied for "maxangle*sin(a)", when a is "much large", it reduces the oscillation to 0);
  • se n=1 it is constant of constant value 1;
  • for a=0 it assumes value 1 any is the value of n (and therefore multiplied for "maxangle*sin(a)" at the beginning, when a=0, it does not have influence.

For how much said, it appears clearly that we must choose an n, than in our case it will be the timesmorz variable, than 0timesmorz<1); if n=1 the power function is always 1 and the oscillation does not come influenced (infinite oscillation). How varies the power function when we modify n between 0 and 1? More next to value 1 is n, slower will be the convergence to the 0, like well demonstrates the figure here under:

 

Notes: according to ActionScript syntax it must write Math.pow(timesmorz,a)

Now we can create the final function, that it encloses sin and power: according to ActionScript syntax it will be

((Math.sin(a))*(Math.pow(timesmorz,a))*maxang

 

What about the n_osc variable? It is used in the function in this mode:

Math.sin(n_osc*a)

its duty is to increase the number of totals oscillations that happen in the same arc of time. Example: if n_osc=1 we will have 20 oscillations in 10 sec, if n_osc=2 we will have 40 oscillations in 10 sec and so on. So, the effect of this variable is, for the final motion, of having a "slow-motion" if n_osc<1 and an accelerated one to the growing of n_osc>1. The definitive function used in the movie is:

((Math.sin(n_osc*a))*(Math.pow(timesmorz,a))*maxang

 

» Level Advanced

Added: 2001-01-18
Rating: 9 Votes: 961
(10 being the highest)
» Author
No author details given.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.