Table Of Contents

3D Coordinate Conversion (G Dataflow)

Last Modified: December 18, 2017

Converts coordinates between the Cartesian, cylindrical, and spherical coordinate systems.

connector_pane_image
datatype_icon

axis 1

X-coordinate in a Cartesian coordinate system, rho-coordinate in a cylindrical coordinate system, or radius-coordinate in a spherical coordinate system.

This input accepts the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

axis 2

Y-coordinate in a Cartesian coordinate system, theta-coordinate in a cylindrical coordinate system, or theta-coordinate in a spherical coordinate system.

This input accepts the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

axis 3

Z-coordinate in a Cartesian coordinate system, z-coordinate in a cylindrical coordinate system, or phi-coordinate in a spherical coordinate system.

This input accepts the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

conversion type

Type of conversion to perform.

Name Value Description
Cartesian to Spherical 0 Converts a coordinate from the Cartesian coordinate system to the spherical coordinate system.
Spherical to Cartesian 1 Converts a coordinate from the spherical coordinate system to the Cartesian coordinate system.
Cartesian to Cylindrical 2 Converts a coordinate from the Cartesian coordinate system to the cylindrical coordinate system.
Cylindrical to Cartesian 3 Converts a coordinate from the cylindrical coordinate system to the Cartesian coordinate system.
Spherical to Cylindrical 4 Converts a coordinate from the spherical coordinate system to the cylindrical coordinate system.
Cylindrical to Spherical 5 Converts a coordinate from the cylindrical coordinate system to the spherical coordinate system.

Default: Cartesian to Spherical

datatype_icon

error in

Error conditions that occur before this node runs.

The node responds to this input according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Default: No error

datatype_icon

converted axis 1

Coordinate on the first axis in the new coordinate system.

This output can return the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

converted axis 2

Coordinate on the second axis in the new coordinate system.

This output can return the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

converted axis 3

Coordinate on the third axis in the new coordinate system.

This output can return the following data types:

  • Double-precision, floating-point number
  • 1D array of double-precision, floating-point numbers
datatype_icon

error out

Error information.

The node produces this output according to standard error behavior.

Standard Error Behavior

Many nodes provide an error in input and an error out output so that the node can respond to and communicate errors that occur while code is running. The value of error in specifies whether an error occurred before the node runs. Most nodes respond to values of error in in a standard, predictable way.

error in does not contain an error error in contains an error
If no error occurred before the node runs, the node begins execution normally.

If no error occurs while the node runs, it returns no error. If an error does occur while the node runs, it returns that error information as error out.

If an error occurred before the node runs, the node does not execute. Instead, it returns the error in value as error out.

Comparing the Cartesian, Cylindrical, and Spherical Coordinate Systems

The Cartesian, or rectangular, coordinate system is the most widely used coordinate system. The cylindrical coordinate system is a generalization of two-dimensional polar coordinates to three dimensions. The spherical coordinate system is a system of curvilinear coordinates that is natural for describing positions on a sphere.

The following figure show a point P in different three-dimensional coordinate systems.

Algorithm for Converting Between Cartesian Coordinates and Cylindrical Coordinates

The following equations describe the relationship between a Cartesian coordinate (x,y,z) and a cylindrical coordinate (ρ,θ,z):

{ x = ρ cos θ y = ρ sin θ z = z

where

  • ρ is the radial coordinate
  • θ (-π < θ ≤ π) is the azimuthal coordinate

Algorithm for Converting Between Cartesian Coordinates and Spherical Coordinates

The following equations describe the relationship between a Cartesian coordinate (x,y,z) and a spherical coordinate (r,θ,φ):

{ x = r sin θ cos φ y = r sin θ sin φ z = r cos θ

where

  • r is the distance from point P to the origin
  • θ (-π < θ ≤ π) is the polar angle in the spherical coordinate system
  • φ (0 ≤ φ ≤ π) is azimuthal angle in the spherical coordinate system

Algorithm for Converting Between Spherical Coordinates and Cylindrical Coordinates

The following equations describe the relationship between a spherical coordinate (r,θ,φ) and a cylindrical coordinate (ρ,θ,z):

{ r = ρ 2 + z 2 θ spherical = atan2 ( ρ , z ) φ = θ cylindrical

where

  • ρ is the radial distance
  • z is the height
  • θspherical (-π < θπ) is the polar angle in a spherical coordinate system
  • θcylindrical (-π < θπ) is the azimuthal angle in a cylindrical coordinate system

Where This Node Can Run:

Desktop OS: Windows

FPGA: This product does not support FPGA devices

Web Server: Not supported in VIs that run in a web application


Recently Viewed Topics