This week's book giveaways are in the Cloud/Virtualization and Go forums.
We're giving away four copies each of Cloud Native Transformation: Practical Patterns for Innovation and The Go Workshop and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native Transformation: Practical Patterns for InnovationE this week in the Cloud/Virtualization forum
or The Go Workshop in the Go forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

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

 
Bartender
Posts: 2429
107
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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: 2429
107
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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: 2429
107
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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...



 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!