move cube on circle

Sry for my English.
I translate right part my cube on invisible circle on right but I would like to stop left side this cube in sphere - see on below images:


now left side my cube is in the same position like right part during translation :stuck_out_tongue:

This is my code:


if (rotateValueZ <= 0) rotateValueZ = 360;
    else rotateValueZ -= 1;

	//cube:
	glLoadIdentity();	
	glTranslatef(5.0f, 10.0f, -70.0f);
	glTranslatef(5.0f * cos(PI * rotateValueZ / 180), 5.0f * sin(PI * rotateValueZ / 180), 0);
	glRotatef(90.0f, 0.0f, 0.0f, 1.0f);
	glScalef(0.02f, 1.0f, 0.02f);
    glutSolidCube(50.0f);

	//circle:
    glLoadIdentity();
    glTranslatef(-20.0f, 10.0f, -70.0f);
    glTranslatef(float(5.0f) * cos(2 * 3.14 * rotateValueZ / 360), 0, 0);
    glutSolidSphere(1.5, 7, 7);

I have added:


glRotatef(asin(5.0f / 50.0f) * 180 / PI * sin(PI * rotateValueZ / 180), 0, 0, 1);

ant it works but I don’t understand this code - can somebody tell me how it works ?

ant it works but I don’t understand this code - can somebody tell me how it works?

Hmmm u have added this statement so u should be in a better position to answer this not us.

I have found this code in google.