Question

back in uni i remember there being an algorithm that's use to calculate the x and y position of point between the x and y values of 2 key frames, i know the one for a straight line

x = ((KeyFrame2.x - KeyFrame1.x)/duration)*time

my understanding is that the difference between the the 2 key frames divided by the duration give you how how many units of measurement (be it pixels mostly), for every unit of time (normally 1 frame) so you just multiply that value by how far though the timeline is

ie. x = ((KeyFrame2.x - KeyFrame1.x)/duration)*time
x = ((10 - 0)/10)*3
x = (10/10)*3
x = 1*3
x = 3 (after 3 units of time, the object's position will be +3 pixels along the x axis from KeyFrame1)

this one i understand however there i was also told about one that it used for curve paths, say a ball bouncing foward and the keyframes are when it hits the ground and when it's at the peek of it's bounce, this one is what i've forgotten and i have no idea where the hell my notes are for it

what i am asking is the algorithm used to calculate the x and y positions for an object with a path like this, i am asking for the mathematical algorithm which is code interdependent, what i'm trying to do is animate a number of orbs that will circle the center of the screen for a logo, i've got the objects in code to move however i need to adjust the calculations between keyframes

NOTE: even though i'm not asking for code, the algorithms are used in animation programming and as such my question relates to programming in general

NOTE2: KeyFrame2.x and KeyFrame1.x are not code, i see keyframes as an instance of a class which holds values such as x ,y, z, duration from previous frame ect

Was it helpful?

Solution

You're not asking for algorithms, you're asking for equations. You can use various equations based on what kind of motion you're simulating; for example, projectile motion under gravity is described by a parabola -- a curve of the form

x = a * y^2 + b

For motion controlled by some intelligent force, curve-fitting based on higher-order polynomials or Bezier curves are more appropriate. Google is your friend here.

OTHER TIPS

If you know that you have circle movement you can circle equation to predict next position or to interpolate between. Since circle can be uniquely defined by 3 points, you need 3 points to interpolate in-between. It makes sense, having only 2 points you cant even know if it is convex or concave circle.

based on movement your points will have, you pick equation that is at least similar to movement you have. In most cases linear equation as you pointed out is just good enough.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top