Conversion between axes coordinate systems

Perform various axes related transformations

  • Transformation between Cartesian, polar, cylindrical, spherical and compass coordinate systems.

  • Create a rotation matrix for rotations around a certain axis.

Cartesian coordinates: x, y, z axes.

Spherical coordinates: - r: length of vector. - theta: angle of the vector to the z-axis. - phi: angle of vector to the x-axis in x,y-plane, rotating counterclockwise.

Cylindrical and polar coordinates: - r: length of vector in x,y-plane. - phi: angle of vector to the x-axis in x,y-plane, rotating counterclockwise. - z: height above x,y-plane.

Compass coordinates: - r: length of vector in x,y-plane. - alpha: angle of vector to the y-axis in x,y-plane, rotating clockwise. - z: height above x,y-plane.

sapphire.transformations.axes.cartesian_to_spherical(x, y, z)

Converts Cartesian coordinates into spherical coordinates

Parameters:

x,y,z – Cartesian coordinates.

Returns:

tuple of spherical coordinates (r, theta, phi), with theta and phi in radians.

sapphire.transformations.axes.cartesian_to_cylindrical(x, y, z)

Converts Cartesian coordinates into cylindrical coordinates

Parameters:

x,y,z – Cartesian coordinates.

Returns:

tuple of cylindrical coordinates (r, phi, z), with phi in radians.

sapphire.transformations.axes.cartesian_to_polar(x, y)

Converts Cartesian coordinates into polar coordinates

Parameters:

x,y – Cartesian coordinates.

Returns:

tuple of polar coordinates (r, phi), with phi in radians.

sapphire.transformations.axes.cartesian_to_compass(x, y, z)

Converts Cartesian coordinates into compass coordinates

Parameters:

x,y,z – Cartesian coordinates.

Returns:

tuple of compass coordinates (r, alpha, z), with alpha in degrees.

sapphire.transformations.axes.spherical_to_cartesian(r, theta, phi)

Convert spherical coordinates into Cartesian coordinates

Parameters:

r,theta,phi – spherical coordinates, with theta and phi in radians.

Returns:

tuple of Cartesian coordinates (x, y, z).

sapphire.transformations.axes.cylindrical_to_cartesian(r, phi, z)

Convert cylindrical coordinates into Cartesian coordinates

Parameters:

r,phi,z – cylindrical coordinates, with phi in radians.

Returns:

tuple of Cartesian coordinates (x, y, z).

sapphire.transformations.axes.polar_to_cartesian(r, phi)

Convert polar coordinates into Cartesian coordinates

Parameters:

r,phi – polar coordinates, with phi in radians.

Returns:

tuple of Cartesian coordinates (x, y).

sapphire.transformations.axes.compass_to_cartesian(r, alpha, z)

Converts compass coordinates into Cartesian coordinates

Parameters:

r,alpha,z – compass coordinates, with alpha in degrees.

Returns:

tuple of Cartesian coordinates (x, y, z).

sapphire.transformations.axes.rotate_cartesian(x, y, z, angle, axis='z')

Rotate Cartesian coordinates

Parameters:
  • x,y,z – Cartesian coordinates.

  • angle – amount of rotation in radians.

  • axis – the axis to rotate around, either 'x', 'y', 'z', or a (x,y,z) tuple specifying the axis to rotate about.

Returns:

tuple of Cartesian coordinates (x, y, z).

sapphire.transformations.axes.rotation_matrix(angle, axis='z')

Generate a rotation matrix around an axis

Parameters:
  • angle – amount of rotation in radians.

  • axis – the axis to rotate around, either 'x', 'y', 'z', or a (x,y,z) tuple specifying the axis to rotate about.

Returns:

unitary rotation matrix.