I'm implementing a touch screen interface whereby the user dragging their finger on the screen will rotate the camera in a sphere around the central point.  My code works well for the horizontal swipe (rotation around the y axis), but only covers a smaller angle from the vertical swipe (rotation around the x axis) instead of the full 360. I used the article - Spherical coordinate system form Wikipedia (), specifically the Cartesian Coordinates section, to do this. I've posted my code below. Can anyone help get this working through the full 360 degrees on both axis? See how Google Earth works when you swipe the globe for what I want.  This must have been done a billion times, but Google searches confuse with the phone built in camera, gps and the like. Thanks!  //Get current position oldX = getPosition().x; oldY = getPosition().y; oldZ = getPosition().z;  //convert to inclination/azimuth camRadius = Math.sqrt((oldX * oldX) + (oldY * oldY) + (oldZ * oldZ)); inclinationTheta = Math.acos(oldZ / camRadius); azimuthPhi = Math.atan2(oldY,oldX);  . . .  //use touch screen changes (deltaTouchX and Y) inclinationTheta = (inclinationTheta + deltaTouchScreenX) % (2 * pi); azimuthPhi = (azimuthPhi + deltaTouchScreenY) % (2 * pi);  //get new co-ordinates newX = camRadius * Math.sin(inclinationTheta) * Math.cos(azimuthPhi); newY = camRadius * Math.sin(inclinationTheta) * Math.sin(azimuthPhi); newZ = camRadius * Math.cos(inclinationTheta);  //set new position setPosition(newX, newY, newZ);
I'm drawing a scene where the camera freely moves about the universe.  The camera class keeps track of the view (or look at) point, the position of the camera, and the up vector.  These vectors/points are then passed into gluLookAt.    Pan and zoom are nearly trivial to implement.  However, I'm finding rotation about the look at point to be much more of an issue.  I want to write a function Camera.rotate that takes 2 angles, one that rotates up/down and one that rotates left/right along an imaginary sphere that is centered about the look at point.  Is there an easy way to do this?  I've (briefly) read about quaternions, but I wanted to see if there was an easier solution given the relatively simple construction of my scene.
I can't not be pregnant Algorithm faster than Newton's for calculating $\sqrt{2}$ Volume of an n-simplex It's rather tedious to show using Fubini's Theorem and induction on $n$ that the volume of the region $x_1+x_2+...+x_n \leq 1$ with $x_1,...,x_n$ nonnegative is $\frac{1}{n!}$.  Is there an easier way to see this? When do I need to invoke \phantomsection? How can I prevent spam on sites which I control? This is a general, community wiki question to address all non-specific spam prevention questions.  If your question was closed as a duplicate of this question and you feel that the information provided here does not provide a sufficient answer, please open a discussion on .    For purposes of this question, spam will include:   Any automated post Manually-posted content which includes links to spammers' sites Manually-posted content which includes instructions to visit a spammer's site Question mark or period to end a rhetorical sentence Which makes more sense as end punctuation for the following rhetorical sentence—a period or a question mark?     Maybe you could be a security guard there and enforce whatever the WalMart policy is at that location How can I convert a complex number into an exponent form Can I see why a package is installed? For a specific package, can I find out why it is installed?  So, can I see or it's manually installed, or that it is installed as a dependency of another package? Or that it is installed as part of the distro? I'm thinking that one way Jeff and the Stack Overflow team could squeeze some extra money out of this site would be to automatically convert all Amazon links posted here into affiliate links, e.g. Stick "tag=codinghorror-20" (or more likely a new site-specific tag) onto every Amazon link. This would bring in some additional revenue every time someone purchased a book via a link on this site.   They could do similar things with other links as well. Amazon's simply the most obvious choice.  So my question is, would anyone have a problem with this?  I know I wouldn't mind, but I don't know how other people would react.  What does everyone think? Is this a horrible idea, a great idea, a waste of time? I have recently installed lubuntu 11.10 on my old laptop (acer aspire 5315 celeron) and observed that fan is not working properly on lubuntu side.I find it strange that it is working perfectly under window vista.   How could I solve this problem? The advantages and disadvantages of using Kaiser Rule to select the number of principal components Send authors an inbox message if their question is closed Permission denied, are you root? How can I get more of this macro photo in focus? I want to make a full focus on the body, for example: I need to have a clear focus on the each balls in the photo. I used just single point focus.    In this picture I used:   shutter speed: 8 aperture: F/4 ISO: 200 2 flashes, one in the right and one on the top of project camera: nikon d300s lens : 105mm micro 2.8   Thanks dpkg: error: parsing file '/var/lib/dpkg/updates/0045' near line 0: What is the difference between "gerund" and "infinitive"? What is the difference between "gerund" and "infinitive"? I do not understand the differences.Can you explain them? Word for person who looks for flattery What word could be used to describe a person who seeks and seems to depend on constant positive feedback from the people around him. Android app - can I see interesting questions? On the website the default list of questions displays interesting tab (which I believe has questions based on my highest scoring tabs). That's very convenient and allows me to check new questions that are relevant for me easily.   Can the same view be added to the mobile app? Can you use Uncanny Dodge against extra damage effects? What is the best base to use?