/// <summary> /// Converts from euclidean to spherical coordiantes. /// (x,y,z) = (radius, azimuth, polar) /// </summary> /// <returns></returns> public Vec3d ToSpherical() { double r = Length; return(new Vec3d(r, Math.Atan(Y / X), SlurMath.AcosSafe(Z / r))); }
/// <summary> /// Returns the minimum angle between two vectors. /// </summary> /// <param name="v0"></param> /// <param name="v1"></param> /// <returns></returns> public static double Angle(Vec3d v0, Vec3d v1) { var d = v0.SquareLength * v1.SquareLength; return(d > 0.0 ? SlurMath.AcosSafe(Dot(v0, v1) / Math.Sqrt(d)) : 0.0); }