• Create Account

# Need application to graphically plot 2D paths

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1EpicCupcakes  Members   -  Reputation: 123

Like
0Likes
Like

Posted 07 September 2012 - 06:28 PM

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?

### #2kidman171  Members   -  Reputation: 445

Like
1Likes
Like

Posted 08 September 2012 - 01:00 AM

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

Edited by kidman171, 08 September 2012 - 01:01 AM.

### #3EpicCupcakes  Members   -  Reputation: 123

Like
0Likes
Like

Posted 10 September 2012 - 08:18 PM

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.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS