   circle path
  In a 2D game I have 2 sprites, s1, and s2, i want s1 to orbit around s1 clockwise when i press one button, and and counterclockwise when i press the other.  All i need to do is figure out the math, but i am so lost.Anyone able to help?   
  Tell us what graphics library or API you're using, and what you have available math-library wise (e.g. vector class and so on).   ;  I'm using Java 1.5 using GTGE engine.  Not much in the engine to do this, i can move it based on an angle, i get get the radius, and the x/y of each.   ;  Here is the easiest and simplest way to do what you want (C-ish pseudocode):if ( LEFT_KEY) { /* make the angle smaller/bigger */ }if (RIGHT_KEY) { /* make the angle bigger/smaller */ }s2.x = s1.x + cos(angle) * radius;s2.y = s1.y + sin(angle) * radius;If that doesn't meet your needs, you might describe more fully what the objects are and what they're doing (e.g. planets in a solar system or what have you).   ;  Hmmmm... I've tried that equation many times, and can't seem to get it to work.  Basicully what I am trying to do is the following.s1 is heros2 is mousepress UP: s1 move towards s2press DOWN: s1 moves away from s2press LEFT: s1 moves around s2 CCWpress RIGHT: s1 moves around s2 CWI may be calculating the angle incorrectly, but I don't think so.   ;Quote:Original post by fubzI may be calculating the angle incorrectly, but I don't think so.I'm not sure then; perhaps you could post your code.   ;  angle = arctan( (s2.y - s1.y)/(s2.x - s1.x) );   ;Quote:Original post by fubzangle = arctan( (s2.y - s1.y)/(s2.x - s1.x) );It looks like you're doing something different than I thought; here you're trying to find the angle from s1 to s2.The above probably won't work, for a few reasons. C++ has a very helpful function, atan2(), which works around these problems. Do you have anything like that available?In any case, the 'atan' function will only return an angle in the range [-90,90] (in degrees), and also may fail when s2.x-s1.x is small. If you don't have something like atan2(), you may need to write your own function to determine the angle. I'll try to sketch one out for you, but I may or may not get it right:vector2 diff = s2-s1;diff.normalize();if (diff.x < -1.0) diff.x = -1.0;if (diff.x >  1.0) diff.x =  1.0;float angle = acos(diff.x);if (diff.y < 0.0) angle = -angle;;  In my code i do in fact get an angle from 0' to 360' (0 - 2PI), i do some finagaling but it works.Java does have an atan2, i will try that out.   ;  WOW! It works!  After working on it all night, liturally.  Now its time to figure out how to change the direction it rotates (CW vs CCW)Thank you very much jyk   