bbi.math.utils

calculate_rotation_matrix_for_vector(from_vec: Vector3, to_vec: Vector3) ndarray

Calculates the 3D rotation matrix that rotates one Vector3 to align with another Vector3.

Parameters:
  • from_vec (Vector3) – Initial 3D vector to be rotated.

  • to_vec (Vector3) – Target 3D vector to align with.

Returns:

A 3x3 rotation matrix.

Return type:

ndarray

matrix_to_euler_degrees(r_mat: ndarray) Vector3

Extract Euler angles (roll, pitch, yaw) from a rotation matrix. The results are left-handed, x-foward z-up y-right coordinate system.

Parameters:

R (ndarray) – A 3x3 rotation matrix.

Returns:

Vector containing the Euler angles (yaw, pitch, roll) in degrees.

Return type:

Vector3

calculate_look_at_rotation(source_position: Vector3, target_position: Vector3) Vector3

Calculate the rotation needed to look from one point towards another point.

Note

When turning to look at a point, only pitch and yaw are relevant. Roll is unnecessary and will be set to zero.

Parameters:
  • source_position (Vector3) – The position to look from

  • target_position (Vector3) – The position to look at

Returns:

The rotation in degrees (0, pitch, yaw)

Return type:

Vector3