   looking around...
  Hi all, I'm using openGL gluLookAt to look at things in my generated world. I have...eyeX,eyeY,eyeZ, the point which I am viewing from, andcenterX,centerY,centerZ, the point which I am looking at.deltaDist is the distance which is a straight line drawn from the viewing point and the point I am viewing.Here's my code...else if(CGRectContainsPoint([left frame], gestureStartPoint)){angle = angle + 0.017453;float deltaDist = sqrtf((centerY - eyeY)*(centerY - eyeY) + (centerX - eyeX)*(centerX - eyeX));float moveY = deltaDist * sinf(angle);float moveX = deltaDist - deltaDist*cosf(angle);centerY = centerY - moveY;centerX = centerX + moveX;}else{angle = angle - 0.017453;float deltaDist = sqrtf((centerY - eyeY)*(centerY - eyeY) + (centerX - eyeX)*(centerX - eyeX));float moveY = deltaDist * sinf(angle);float moveX = deltaDist - deltaDist*cosf(angle);centerY = centerY + moveY;centerX = centerX - moveX;}...0.017453 is 1 degree in radians. The if-else conditions are correct, what I'm puzzled about is the maths behind it.I don't have a picture so I will try my best to describe.Imagine a large circle, and the viewer is in the exact center of the circle. So eyeX,Y and Z should be the point in the center of the circle. The viewer is trying to view any point on the circumference of the circle, so centerX,Y and Z could be any point on the circumference. By default, the viewer is looking straight up, and the angle = 0. If the left arrow is pressed(the first condition) then angle will increase by 1 degree, the calculations would take place and centerX and Y would be corrected. If the right arrow is pressed(second condition) the opposite is true.The Z coordinate is upwards, Y coordinate is horizontal, and the X coordinate is facing out of the screen.Unfortunately after alot of trial and error the code still doesn't work right, for example, after 90 degrees the calculations reverse itself, the left become right and right becomes left. Also, if the code is right deltaDist, which is supposed to be the radius of the circle, shouldn't change at all, I logged it and it changes.any help would be much appreciated thanks.   
  Look up converting polar coordinate to cartesian coordinates.Basically there are two arcs, two angles, heading and elevation.You compute the outcome of the first arc based on the heading direction. Then you imagine a plane interseting the resultant edge of this arc and the orign and compute your elevation arc in this plane. While the vertical component should be scaled by sin as you noticed, the other two dimensions need to be scaled by cos of the elevation.//i chose z and x in this order due to the right hand rulefloat z = cos(heading);float x = sin(heading);float y = sin(elevation);z *= cos(elevation);x *= cos(elevation);You can then scale all these but by some radius if you want, but that's not necessary. A unit length vector is plenty to define a direction vector to add to your look from point.You should note (and may be experiencing it), this form of "look around" is very prone to gimbal lock. If elevation is 90 degrees. Straight up, like you mentioned, then as you see heading will have zero effect. Its axis will be aligned with the elevation.The only way to prevent this is to not store polar coordinates but to store the vectors themselves. You'd then change the vector with an incremental rotation angle rather than changing the current absolute one.Vector viewDirection(1,0,0);Vector viewRight(0,0,1);Vector viewUp(0,1,0);void IncrementViewDirection(float incElevationAngle, float incHeadingAngle){  Matrix mE(AxisAngle(viewRight, incElevationAngle);  Matrix mH(AxisAngle(worldUp, incHeadingAngle);  Matrix mTotal = mH * mE;  viewDirection = mTotal * viewDirection;  viewRight = mTotal * viewRight;  viewUp = Cross(ViewRight, viewDirection);} Then use viewDirection, and viewUp to call gluLookAt().[Edited by - bzroom on June 17, 2009 4:20:06 PM]