Share My Creation Bézier curve - My own algorithm

hi,

all started with an idea how to make a round path to move a spaceship on my screen like in Galaga.

so to move a sprite on the screen i can use FollowPath(...) in SpriteKit and i just need to define a path with x points. the problem is how to do a nice round moving of the sprite?? so i thought to check how round curves are done and i found the Bezier curve: https://en.wikipedia.org/wiki/Bézier_curve

the problem is i dont understand how it works and those formulas are like Chinese for me so i wrote my own algorithm.

when i was a child i remember that someone showed me how you can draw a nice curve with only straight lines and i was fascinated by that. it looked like that:


curve.png


so what you do is basically draw 2 lines and then draw an equal size of small lines to the 2 lines and just connect small line 1 from line 1 to small line 1 from line 2. at the end you will have a perfect curve (it depends on how much steps you do it)

anyway i simulate the same scenario in my algorithm and this is what i end up with (download Jar and have a look)

PS: i know that most of you here are math pros (like @klaus) and you will post a very simple formula and tell me how simple this is but i am very happy i could come up with my own way to solve the problem even if it is not the perfect way but it's my own "Home Made" (and also maybe first) algorithm :p
 

Attachments

  • BezierCurve.jar
    358.7 KB · Views: 240
Last edited:
Top