Skip to main content

Coordinate system converters

The following coordinate system converters are available in CoordinateConverters namespace, which complements View3D usage.

  • Cartesian 3D ⇔ Spherical 3D
  • Cartesian 3D ⇔ Cylindrical 3D

SphericalCartesian3D

SphericalCartesian3D converter class converts between spherical and 3D cartesian coordinates.

View3D SphericalCartesian3D
Example created with SphericalCartesian3D converter. Data points of SurfaceMeshSeries3D and the grid are defined in spherical coordinates. Annotation tracks the nearest data point and displays its value in spherical coordinates.

Spherical data points are defined by SphericalPoint objects which contain the following fields:

  • Distance: Distance from origin (0,0,0)
  • ElevationAngle: Elevation angle. Also called as Elevation or Altitude, measured from XZ plane. ElevationAngle is 90 degrees - Inclination angle.
  • HeadingAngle: Heading angle. Also called as azimuth and absolute bearing

For elevation, the XZ plane is the reference plane. (e.g. equatorial plane). Elevation is an angle measured from that plane.

note

This converter class expects the View3D.Dimensions to be equal (cubic), otherwise the conversion result may have to be scaled by user-side code.

View3D’s series typically take the data input as X, Y, Z values. These values can be found e.g. in SeriesPoint3D, SurfacePoint3D and PointDouble3D objects.

Converting from spherical to cartesian

To convert a SphericalPoint to cartesian coordinate, use SphericalCartesian3D. ToCartesian() method. It accepts data input as

  • SphericalPoint point
  • SphericalPoint[] array
  • SphericalPoint[,] matrix

Alternatively, convert by using ToCartesian() extension method for spherical points.

// Create spherical points matrix
SphericalPoint[,] sphericalData = CreateSurfaceData();
// Convert matrix to cartesian matrix
SurfacePoint[,] xyzData = sphericalData.ToCartesian();

Converting from cartesian to spherical

To convert a cartesian point to spherical point, use SphericalCartesian3D. ToSpherical() method. It accepts data input as PointDouble3D point with X, Y and Z fields.

Alternatively, convert a point by using ToSpherical() extension method.

// Define cartesian point
PointDouble3D point = new PointDouble3D(50, 20, 40);
// Convert to spherical point
SphericalPoint sp = point.ToSpherical();

CylindricalCartesian3D

Converter class to convert between cylindrical and 3D cartesian coordinates.

View3D CylindricalCartesian3D
Example created with CylindricalCartesian3D converter. Data points of SurfaceMeshSeries3D and the grid are defined in cylindrical coordinates. Annotation tracks the nearest data point of a PointLineSeries3d and displays its value in cylindrical coordinates.

Cylindrical points are defined by CylindricalPoint objects, which contain the following fields:

  • Distance: Distance along XZ plane
  • Y: Y value
  • Angle: Heading angle, also called as azimuth and absolute bearing
note

This converter class expects View3D.Dimensions.X and View3D.Dimensions.Z to be equal, otherwise the conversion result regarding Angle and Distance (or X and Z) may have to be scaled by user-side code.

View3D’s series typically take the data input as X, Y, Z values. These values can be found e.g. in SeriesPoint3D, SurfacePoint3D and PointDouble3D objects.

Converting from cylindrical to cartesian

To convert a CylindricalPoint to cartesian coordinate, use CylindricalCartesian3D. ToCartesian() method. It accepts data input as

  • CylindricalPoint point
  • CylindricalPoint[] array
  • CylindricalPoint[,] matrix

Alternatively, convert by using ToCartesian() extension method for cylindrical points.

// Create cylindrical points matrix
CylindricalPoint[,] cylindricalData = CreateData();
// Convert matrix to cartesian matrix
SurfacePoint[,] xyzData = cylindricalData.ToCartesian();

Converting from cartesian to cylindrical

To convert a cartesian point to cylindrical point, use CylindricalCartesian3D. ToCylindrical() method. It accepts data input as PointDouble3D point with X, Y and Z fields.

Alternatively, a point can be converted by using ToCylindrical() extension method.

// Define cartesian point
PointDouble3D point = new PointDouble3D(50, 20, 40);
// Convert to cylindrical point
CylindricalPoint sp = point.ToCylindrical();

Examples

info

To see feature demonstration as example, check SphericalSurface and ExampleCylindrical from our Demo.