/// <summary> /// Converts to spherical coordinates. /// </summary> /// <returns>SphericalCoordinate.</returns> public static SphericalCoordinate ToSpherical(CartesianCoordinate3D coordinate) { double radialDistance = AlgebraLibrary.SRSS(coordinate.X, coordinate.Y.Squared(), coordinate.Z.Squared()); double angleAzimuth = NMath.Atan(coordinate.Y / coordinate.X); double angleInclination = NMath.Acos(coordinate.Z / radialDistance); return(new SphericalCoordinate(radialDistance, angleInclination, angleAzimuth, coordinate.Tolerance)); }
/// <summary> /// Initializes the class with a vector structure. /// </summary> /// <param name="xMagnitude">The x magnitude.</param> /// <param name="yMagnitude">The y magnitude.</param> /// <param name="zMagnitude">The z magnitude.</param> /// <param name="tolerance">The tolerance.</param> public Vector3D( double xMagnitude, double yMagnitude, double zMagnitude, double tolerance = Numbers.ZeroTolerance) { _location = new CartesianCoordinate3D(); Xcomponent = xMagnitude; Ycomponent = yMagnitude; Zcomponent = zMagnitude; Tolerance = tolerance; }
/// <summary> /// Converts to cylindrical coordinates. /// </summary> /// <returns>CylindricalCoordinate.</returns> public static CylindricalCoordinate ToCylindrical(CartesianCoordinate3D coordinate) { double radialDistance = AlgebraLibrary.SRSS(coordinate.X, coordinate.Y); double height = coordinate.Z; double angleAzimuth = 0; if (coordinate.X.IsZeroSign() && coordinate.Y.IsZeroSign()) { angleAzimuth = 0; } else if (coordinate.X.IsGreaterThanOrEqualTo(0) && !coordinate.Y.IsZeroSign()) { angleAzimuth = NMath.Asin(coordinate.Y / radialDistance); } else if (coordinate.X.IsNegativeSign()) { angleAzimuth = -NMath.Asin(coordinate.Y / radialDistance) + Numbers.Pi; } return(new CylindricalCoordinate(radialDistance, height, angleAzimuth, coordinate.Tolerance)); }
/// <summary> /// Determines whether the coordinate lies within the extents. /// </summary> /// <param name="coordinate">The coordinate.</param> /// <returns><c>true</c> if the specified coordinates are within the extents; otherwise, <c>false</c>.</returns> public abstract bool IsWithinExtents(CartesianCoordinate3D coordinate);