Help!
I've seen some things...
like
double AngleBetweenVector(Vector3 A, Vector3 B)
{
return Math.Acos(Vector3.DotProduct(A, B) /
Math.Sqrt(Vector3.DotProduct(A, A) * Vector3.DotProduct(B, B)));
}
but...this only returns one angle...
In 3d space, vectors are composed of 3 vertices... to get to another vector, you need two angles to offset the vector on two of the axises. One angle is not enough.
Such is the make up of the calculation to find the point on the surface of a sphere:
public static Vector3 GetPointOnSphere(Vector3 sphereOrigin, double radius, double theta, double psi)
{
Vector3 results = new Vector3();
if ((psi >= 0 && psi <= (2 * Math.PI)) && (theta >= 0 && theta <= Math.PI))
{
// x = x0 + r * Sin theta * cos psi
// y = y0 + r * sin theta * sin psi
// z = z0 + r * cos theta
results.X = sphereOrigin.X + radius * Math.Sin(theta) * Math.Cos(psi);
results.Y = sphereOrigin.Y + radius * Math.Sin(theta) * Math.Sin(psi);
results.X = sphereOrigin.X + radius * Math.Cos(theta);
}
return results;
}
It takes TWO angles.
So, thinking about two spheres, that are touching, in any orientation, in 3d space, how do I find theta and psi from the theoretical line made from the centre of sphere 1 to the centre of sphere 2, in relation to sphere 2?
Help! Thanks!
R