I have two specific points, C and P.
My goal is to rotate point P around center C in three dimensions.
How can I determine the new coordinates of point P after rotation?
I am provided with two angles: 'yaw' and 'pitch'.
The 'yaw' angle moves point P around center C along the 'x' axis, causing it to move left or right in relation to the point.
On the other hand, the 'pitch' angle moves point P around center C along the 'y' axis, making it move up or down in relation to the point.
In terms of depth, the 'z' direction moves towards you in a positive manner and away from you in a negative manner.
Naturally, I would like this calculation to also work with intermediate positions, such as when both yaw and pitch are at 45 degrees.
Both Yaw and Pitch angles are initially given in degrees but need to be converted to radians for the code.
p.x = c.x + Math.sin(yaw) * Math.sin(pitch);
p.y = c.y + Math.cos(yaw);
p.z = c.z + Math.cos(yaw) * Math.cos(pitch);
Visualize a sphere with a point on its surface - I aim to move this point along the circumference of the sphere.
While this method works sometimes, there are instances where it does not. What could I be overlooking?
If this inquiry appears redundant, please excuse me as I am unsure what terms to search for.
For further reference, I have included a fiddle showcasing my issue: http://jsfiddle.net/Jm6Lt/2/
The position of the blue sphere is calculated, while the white sphere is rotated around the red sphere's center.