• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Here is how to plot a curve between two points....

 
Bartender
Posts: 2880
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ...

 
salvin francis
Bartender
Posts: 2880
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
salvin francis
Bartender
Posts: 2880
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...



 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic