/// <summary> /// Rotate the current vector around a specified vector from a defined angle in radians. /// </summary> /// <param name="v">Vector used as a rotation axis.</param> /// <param name="theta">Angle of rotation expressed in radians.</param> /// <returns>The coordinates of the resulting rotated vector.</returns> public SphericalVector RotateAround(SphericalVector v, double theta) { if (theta.IsZero()) { return(this); } return(CoordinateConverter.ConvertToSpherical(CoordinateConverter.ConvertToCartesian(this).RotateAroundVector(CoordinateConverter.ConvertToCartesian(v), theta))); }
/// <summary> /// Convert a Spherical Vector to his Cartesian equivalent. /// </summary> /// <param name="sc">Spherical coordinate to convert.</param> /// <returns>The Vector converted to a Cartesian representation.</returns> public static Cartesian3dCoordinate ConvertToCartesian(SphericalVector sc) { double sinTheta = Trigonometry.Sin(sc.Theta); return(new Cartesian3dCoordinate( sinTheta * Trigonometry.Cos(sc.Phi), sinTheta * Trigonometry.Sin(sc.Phi), Trigonometry.Cos(sc.Theta) )); }