float AngleBetween(Vector3 other) { Vector3 a = GetNormalized(); Vector3 b = other.GetNormalized(); float d = a.x * b.x + a.y * b.y + a.z * b.z; return((float)Math.Acos(d)); }
public Vector3 ClosestPoint(Vector3 p) { Vector3 toPoint = p - center; if (toPoint.MagnitudeSqr() > radius * radius) { toPoint = toPoint.GetNormalized() * radius; } return(center + toPoint); }
float AngleBetween(Vector3 other) { // normalise the vectors Vector3 a = GetNormalized(); Vector3 b = other.GetNormalized(); // calculate the dot product float d = a.x * b.x + a.y * b.y + a.z * b.z; // return the angle between them return((float)Math.Acos(d)); }