I’ve read somewhat over 300 pages on the internet, and I didn’t get the result I wanted or either it didn’t work, so I hope people can help me out over here. You can explain by using pseudo code and maths. 🙂
So, we have point A (which is the origin). Point A has a radius, an XYZ position and XYZ rotation (I know it can be done with 2 angles, but I really need it to be with 3 angles).
Point B’s position is unknown.
Armed with that information, my question is: how would I find the position of point B? (Alternatively, my question could be rephrased as: “how to find a 3D point on a sphere?”)
I’ve already done it in 2D and there it worked.
for 2D I used:
x=pointA.x+radius*cos(angle)
y=pointA.y+radius*sin(angle)
I don’t use pure matrices but I want to use cosines and such. My attempt (which fails badly, I really have no idea how to combine XYZ rotations with cosines) in pseudo code:
newx=pointA.x+radius*cos(rotationY)*sin(rotationZ+toRadians(90))
newy=pointA.y+radius*cos(rotationZ-toRadians(90))*math.sin(rotationY)*math.cos(rotationX)
newz=pointA.z+radius*math.cos(rotationZ+toRadians(90))*sin(rotationX)
I would appreciate it so much if someone could help me. 🙂
Suppose that you have a sphere centered at the origin, with known radius, and azimuth and elevation angles. Then you can simply find cartesian coordinates using spherical to cartesian conversion.
So, first take relative B components, with the A radius and your angles. You obtain cartesian components. Then, you can add these relative components to A cartesian components, returning absolute B coordinates. Don’t consider the roll angle, because for a point it’s useless.