Skip to main content
GameDev.net gamedev.net
🔒 Locked

Need application to graphically plot 2D paths

Started by EpicCupcakes Sep 8, 2012 at 12:28 AM 1 replies 1.1k views
Original Post
EpicCupcakes
EpicCupcakes
Hello, all.
I am currently working on a simple 2D card game and I want to add some simple animations to it. All I want is to move the cards along a curved or circular path in order to add a bit of flair to the game when the player draws a card. Does anyone know any programs that would allow me to plot that path graphically and then create a file with that path's data that I can use in my code?
kidman171
kidman171
I personally don't know any applications that let you do that but I'm sure other folks will provide links to programs that do it for you.
However, it's quite easy to programmatically plot a curve and use interpolation to gather points along the curve. For example, here is a function I use that interpolates a cubic bezier curve:


Vec2 cubicBezierInterpolate(Vec2 P0, Vec2 P1, Vec2 P2, Vec2 P3, float t)
{
float u = 1.0f - t;
float tt = t * t;
float uu = u * u;
float uuu = uu * u;
float ttt = tt * t;
Vec2 p = P0 * uuu; // first term
p = p + (P1 * 3.0f * uu * t); // second term
p = p + (P2 * 3.0f * u * tt); // third term
p = p + (P3 * ttt); // fourth term
return p;
}


This function requires that you provide four control points for the curve and an interpolation value between 0 and 1.

If you just want to plot a circle or a simple curve, I recommend you check out this great article on cos and sin: http://www.helixsoft.nl/articles/circle/sincos.htm
EpicCupcakes
EpicCupcakes
Thank you for the code and the article. I found both of them to be very useful. I managed to cobble together a function that fit my needs for animation with it. It almost felt like I was in school again!

And if anyone knows any graphical program used to plot animation, please post or pm me. I'd really appreciate it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.