void sceneTransformation(){
glLoadIdentity( );
GLdouble radx = (GLdouble)(anglex*PI/180.);
GLdouble rady = (GLdouble)(angley*PI/180.);
GLdouble l = sqrt( pow(distX, 2) + pow(distY, 2) + pow(distZ, 2) );
GLdouble phi = atan(distZ/distX) + radx;
GLdouble theta = acos(distY/l) + rady;
// limit what angles theta and phi can take.
if(theta >= 2*PI)
theta = fmod((GLdouble)theta, 2*PI);
if(phi >= 2*PI)
phi = fmod((GLdouble)phi, 2*PI);
GLdouble deltaX = l*sin(theta)*cos(phi);
GLdouble deltaY = l*cos(theta);
GLdouble deltaZ = l*sin(theta)*sin(phi);
GLdouble up_x = deltaX - l*sin(theta-1.0)*cos(phi);
GLdouble up_y = deltaY - l*cos(theta-1.0);
GLdouble up_z = deltaZ - l*sin(theta-1.0)*sin(phi);
gluLookAt((distanceX + deltaX), (distanceY + deltaY), (distanceZ + deltaZ), 0, 0, 0, up_x,up_y,up_z);
}