Hey guys! I am trying to rotate a cone(or any other obj drawn on the screen) using one mouse click. When there is a mouse click, the angle between line joining the origin and the clicked point is calculated and the obj is rotated. However the code doesn’t seem to be working.
The drawn obj like for eg: cone will already be a translated one, drawn using glutWireCone. I’m pasting the partial code here. Please do tell me if i am making any logical error
void rotate(int x,int y)// x,y values returned from mouse call back (the clicked point)
cx=x*1.0; cy=y*1.0; r=asin(cy/cx); r=r*(180/3.1415);//converting radians to degrees printf("
thetha = %f",r);
glRotatef(r, 1.0, 0.0, 0.0); //rotate on the x axis
glRotatef(r, 0.0, 1.0, 0.0); //rotate on the y axis
glRotatef(r, 0.0, 0.0, 1.0);