posted 7 years ago

Hi,

This is not a question, but an answer,

An answer to any one who wants to move an object from point A to point B in a curved way,

An answer to any one who wants to plot a curve from point A to point B

here goes :

The answer to this is Bezier Curve

http://en.wikipedia.org/wiki/B%C3%A9zier_curve

well, i know the content there is way over our heads (at least mine ) but i found one equation there that suited my requirement:

Quadratic Bezier curves

B(t) = (1-t)^2*p0+2(1-t)t*p1+(t^2)*p2

I know it sounds gibberish but let me break it down....

looking at this:

when t=0, this is what happens...

when t=1, this is what happens...

So, there you go...

Happy game development

check out the icons animated in my site using this equation ...

This is not a question, but an answer,

An answer to any one who wants to move an object from point A to point B in a curved way,

An answer to any one who wants to plot a curve from point A to point B

here goes :

The answer to this is Bezier Curve

http://en.wikipedia.org/wiki/B%C3%A9zier_curve

well, i know the content there is way over our heads (at least mine ) but i found one equation there that suited my requirement:

Quadratic Bezier curves

B(t) = (1-t)^2*p0+2(1-t)t*p1+(t^2)*p2

I know it sounds gibberish but let me break it down....

looking at this:

when t=0, this is what happens...

when t=1, this is what happens...

So, there you go...

Happy game development

check out the icons animated in my site using this equation ...

I agree. Here's the better link: Salvin.in

posted 7 years ago

in this code:

(startX,startY) is the starting point coordinate,

(endX,endY) is the ending point coordinate,

and (bezierX,bezierY) is the control point which governs the curvature of the curve,

think in this manner, if this point is farther away, then the curve is more steep..

if this point is closer then the curve is less steep.

(startX,startY) is the starting point coordinate,

(endX,endY) is the ending point coordinate,

and (bezierX,bezierY) is the control point which governs the curvature of the curve,

think in this manner, if this point is farther away, then the curve is more steep..

if this point is closer then the curve is less steep.

I agree. Here's the better link: Salvin.in

posted 7 years ago

Another great equation is the "ease out":

where t is from 0 to 1.

int x = (int) ((1 + Math.cos(Math.PI + t * Math.PI)) / 2);

check the curve when x varies from 0 to 1

http://www.wolframalpha.com/input/?i=plot[(1+%2Bcos(PI+%2B+x*PI))%2F2%2C+{x%2C0%2C1}]

its a slow transition followed by a fast transition followed by a slow transition.

like the way a ball rolls...

try animating an object with the x value varying as per the equation and check the output...

where t is from 0 to 1.

int x = (int) ((1 + Math.cos(Math.PI + t * Math.PI)) / 2);

check the curve when x varies from 0 to 1

http://www.wolframalpha.com/input/?i=plot[(1+%2Bcos(PI+%2B+x*PI))%2F2%2C+{x%2C0%2C1}]

its a slow transition followed by a fast transition followed by a slow transition.

like the way a ball rolls...

try animating an object with the x value varying as per the equation and check the output...

I agree. Here's the better link: Salvin.in

It is sorta covered in the JavaRanch Style Guide. |