newton.Axis#

class newton.Axis(value)[source]#

Bases: IntEnum

Enumeration of axes in 3D space.

classmethod from_any(value)#

Convert a value of various types to an Axis enum member.

Parameters:

value (AxisType) – The value to convert. Can be an Axis, str, or int-like.

Returns:

The corresponding Axis enum member.

Return type:

Axis

Raises:
  • TypeError – If the value cannot be converted to an Axis.

  • ValueError – If the string or integer does not correspond to a valid Axis.

classmethod from_string(axis_str)#

Convert a string representation of an axis (“x”, “y”, or “z”) to the corresponding Axis enum member.

Parameters:

axis_str (str) – The axis as a string. Should be “x”, “y”, or “z” (case-insensitive).

Returns:

The corresponding Axis enum member.

Return type:

Axis

Raises:

ValueError – If the input string does not correspond to a valid axis.

to_vec3()#

Return the axis as a warp.vec3 unit vector.

Returns:

The unit vector corresponding to the axis.

Return type:

wp.vec3

to_vector()#

Return the axis as a 3D unit vector.

Returns:

The unit vector corresponding to the axis.

Return type:

tuple[float, float, float]

X = 0#

X-axis.

Y = 1#

Y-axis.

Z = 2#

Z-axis.