I have a object at the center. Other set of objects rotating around center in first orbit. Now i want other objects to rotate around the objects in 1st orbit.
n the above fig, set of triangles are rotating around the square and circles are rotating around the triangle. I have the code which works for 1st orbit, but i am not able to render that second orbit.
void display()
{
for (int k = 0; k < 10; k++)
{
distance_x = 0.4 * cos(angle1*3.14 / 180);
distance_y = 0.4 * sin(angle1*3.14 / 180);
angle1 += 60;
glPushMatrix();
glRotatef(i, 0.0f, 0.0f, 1.0f);
glTranslatef(distance_x, distance_y, 0.0f);
glRotatef(-i, 0.0f, 0.0f, 1.0f);
DrawTriangle();
glPopMatrix();
}
}
I am calling display in loop. i is static global variable. which transformations will do the second orbit?