Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Arc Math

This topic is 5920 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m working on a simple scripting engine for running moving platforms in my side scroller (a year ago I would have derived a class for every platform in the game ). Working great; I can get it to initialize, move, delay and even set the parser on the fly or wait for the player to jump on it. Now, what I''d like to be able to do is move the platform in an arc. Say I want to move from (600, 850) to (600, 650). 200 pixels straight up. Now, how can I control the curve the platform travels? Maybe I want a very subtle curve. Maybe I''m moving from under a platform to over it and I want a half-circle. Maybe I want the destination and the source to be equal, and for it to move 360. This all works off keyframes, btw, so I want to be able to interpolate by time deltas. I guess I''m looking for math to figure out a path between two points given, say, an angle, or whatever it takes. Like I''d get my half-circle by passing 180 (or a half circle in the other direction with -180) or a more subtle curve with, say 30. Or my circle with 360. Actually, I''d probably be using rads, wouldn''t I? Say I''m going from (600, 850) to (600, 650) and my angle is 180. That makes my midpoint (600, 750). Or if my angle is 90, the midpoint would be (500, 750) (and -90 would be (700, 750)). How do I calculate a midpoint like that? Just so you know, this is how my script language works: start(192, 160); moveto(320, 160, keyframe(256)); stall(keyframe(200)); moveto(320, 480, keyframe(640)); moveto(192, 480, keyframe(128)); moveto(192, 160, keyframe(320)); setparser(16); Platform moves in a rectangular loop, stopping for a second in the upper-right corner (just for testing). Boy; that''s a long post Basically, I want to be able to have an arc(600, 650, 180); if possible. To be able to determine a midpoint of an arc from 2 endpoints and an angle. And I believe (hope) I can them interpolate from one point to another using the angles from the midopoint to the two endpoints. Can anyone show me the math for something like this? Thanks muchly Chris Barry (crbarry at mts.net) My Personal Programming Depot

Share this post

Link to post
Share on other sites
I hope I understand what it is you are asking for... if not, ignore what follows!

Define a set of parametric paths. This set might include: piece-wise linear, spline, parabolic, circular, elliptic, etc., paths that have associated with them boundary constraints (on the domain).

So, for instance you can define a parametric circle using x = r*cos(theta) and y = r*sin(theta), for constant r. You can define a parametric circular arc by constraining theta. Then scale theta to the desired period of rotation you want, based on your platforms speed.

When you want to implement a particular motion, simply choose the path you want from your library of paths and set the parameters you want for it.



Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!