An object that moves in a circle / A c++ program to check if the given path for a object is circular or not #include using namespace std; // Macros for East, North, South and West #define N 0 #define E 1 #define S 2 #define W 3 // This function returns true if the given path is circular, else false bool isCircular(char path[]) { // Initialize starting point for robot as (0, 0) and starting // direction as N North int x = 0, y = 0; int dir = N; // Travers the path given for robot for (int i=0; path[i]; i++) { // Find current move char move = path[i]; // If move is left or right, then change direction if (move == \'R\') dir = (dir + 1)%4; else if (move == \'L\') dir = (4 + dir - 1)%4; // If move is Go, then change x or y according to // current direction else // if (move == \'G\') { if (dir == N) y++; else if (dir == E) x++; else if (dir == S) y--; else // dir == W x--; } } // If robot comes back to (0, 0), then path is cyclic return (x == 0 && y == 0); } An object that continually rotates I\'m trying to simulate the solar system and need to get the moon to orbit a planet orbiting the sun i am currently using the following code to rotate the planets i\'m trying to use the code below to make my moon orbit the earth however at the moment all i can do is rotate around a specific point. glPushMatrix(); glRotated((GLdouble)(spin*earth.speed), 0.0, 0.0, 1.0); glTranslated(earth.xPos, earth.yPos, earth.zPos); earth.draw(); glPopMatrix(); glPushMatrix(); //define one time only start location bool start = true; if (start) { glTranslated(earthMoon.xPos, earthMoon.yPos, earthMoon.zPos); start = false; } //orbit earths start point //perfectly fits around earth glTranslatef(-0.1, -0.1, 0); glRotatef(spin*10, 0, 0, 1); glTranslatef(0.1, 0.1, 0); // need translation vector to follow earth //glTranslated(earthMoon.xPos, earthMoon.yPos, earthMoon.zPos); earthMoon.draw(); glPopMatrix(); i think what i need to do is find some way of knowing earths position from the rotatef function. I have a class for the planets with the following attributes and methods: float radius; float xPos; float yPos; float zPos; float speed; planet(float r, float x, float y, float z, float speed); ~planet(); void draw(void) { glPushMatrix(); glColor3f(0.0, 1.0, 1.0); glutSolidSphere(radius, 20, 10); glPopMatrix(); } Solution An object that moves in a circle / A c++ program to check if the given path for a object is circular or not #include using namespace std; // Macros for East, North, South and West #define N 0 #define E 1 #define S 2 #define W 3 // This function returns true if the given path is circular, else false bool isCircular(char path[]) { // Initialize starting point for robot as (0, 0) and starting // direction as N North int x = 0, y = 0; int dir = N; // Travers the path given for robot for (int i=0; path[i]; i++) { // Find current move char move = path[i]; // If move is left or right, then change direction if (move == \'R\') dir = (dir + 1)%4; else if (move == \'L\') dir = .