pyrfuniverse.utils package

pyrfuniverse.utils.depth_processor module

pyrfuniverse.utils.rfuniverse_utility module

pyrfuniverse.utils.rfuniverse_utility.EncodeIDAsColor(instance_id: int)

Encode the object id to a color.

Parameters:

instance_id – Int, the id of the object.

Returns:

The encoded color in [r, g, b, 255] format.

Return type:

List

pyrfuniverse.utils.rfuniverse_utility.UnityEularToQuaternion(eular: list) list

Transform euler angle to quaternion in Unity.

Parameters:
  • eular – List of length 3, representing euler angle in [x, y, z]

  • degree. (order and measured in) –

Returns:

The transformed quaternion in [x, y, z, w] format.

Return type:

List

pyrfuniverse.utils.rfuniverse_utility.UnityQuaternionToEular(quaternion: list) list

Transform quaternion to euler angle in Unity.

Parameters:
  • quaternion – List of length 4, representing quaternion in [x, y, z, w]

  • order.

Returns:

The transformed euler angle in [x, y, z] order and measured in degree.

Return type:

List

pyrfuniverse.utils.rfuniverse_utility.GetMatrix(quat=[0, 0, 0, 1]) ndarray

Transform the position and quaternion into a transformation matrix.

Parameters:

quat – List of length 4, representing the [x, y, z, w] quaternion.

Returns:

the transformation matrix.

Return type:

numpy.ndarray

pyrfuniverse.utils.coordinate_system_converter module

class pyrfuniverse.utils.coordinate_system_converter.CoordinateSystemConverter(cs1_direction=['right', 'up', 'forward'], cs2_direction=['right', 'up', 'forward'])

Bases: object

Coordinate System Converter class.

Parameters:
  • cs1_direction – list, The visual direction corresponding to the xyz axis, can be: [“left”/”right”/”up”/”down”/”forward”/”back”/ “l”/”r”/”u”/”d”/”f”/”b”/ “-left”/”-right”/”-up”/”-down”/”-forward”/”-back”/ “-l”/”-r”/”-u”/”-d”/”-f”/”-b”]

  • cs2_direction – list, The visual direction corresponding to the xyz axis, can be: [“left”/”right”/”up”/”down”/”forward”/”back”/ “l”/”r”/”u”/”d”/”f”/”b”/ “-left”/”-right”/”-up”/”-down”/”-forward”/”-back”/ “-l”/”-r”/”-u”/”-d”/”-f”/”-b”]

cs1_pos_to_cs2_pos(pos: list) list

Convert position form Coordinate System 1 to Coordinate System 2.

Parameters:

pos – List of length 3, position of Coordinate System 1.

Returns:

List of length 3, position of Coordinate System 2.

Return type:

list

cs2_pos_to_cs1_pos(pos: list) list

Convert position form Coordinate System 2 to Coordinate System 1.

Parameters:

pos – List of length 3, position of Coordinate System 2.

Returns:

List of length 3, position of Coordinate System 1.

Return type:

list

cs1_quat_to_cs2_quat(quat: list) list

Convert quaternion form Coordinate System 1 to Coordinate System 2.

Parameters:

quat – List of length 3, quaternion of Coordinate System 1.

Returns:

List of length 3, quaternion of Coordinate System 2.

Return type:

list

cs2_quat_to_cs1_quat(quat: list) list

Convert quaternion form Coordinate System 2 to Coordinate System 1.

Parameters:

quat – List of length 4, quaternion[x,y,z,w] of Coordinate System 2.

Returns:

List of length 4, quaternion[x,y,z,w] of Coordinate System 1.

Return type:

list

cs1_scale_to_cs2_scale(scale: list) list

Convert scale form Coordinate System 1 to Coordinate System 2.

Parameters:

scale – List of length 3, scale of Coordinate System 1.

Returns:

List of length 3, scale of Coordinate System 2.

Return type:

list

cs2_scale_to_cs1_scale(scale: list) list

Convert scale form Coordinate System 2 to Coordinate System 1.

Parameters:

scale – List of length 3, scale of Coordinate System 2.

Returns:

List of length 3, scale of Coordinate System 1.

Return type:

list

cs1_matrix_to_cs2_matrix(matrix) ndarray

Convert rotation matrix form Coordinate System 1 to Coordinate System 2.

Parameters:

matrix – list or np.ndarray shape[3,3], rotation matrix of Coordinate System 1.

Returns:

shape[3,3], rotation matrix of Coordinate System 2.

Return type:

np.ndarray

cs2_matrix_to_cs1_matrix(matrix) ndarray

Convert rotation matrix form Coordinate System 2 to Coordinate System 1.

Parameters:

matrix – list or np.ndarray shape[3,3], rotation matrix of Coordinate System 2.

Returns:

shape[3,3], rotation matrix of Coordinate System 1.

Return type:

np.ndarray