sksurgerycore.transforms.matrix module

Construct 3x3 rotation matrices for rotating around the x, y and z axes individually, as well as 3x3 rotation matrices from sequences of three Euler angles.

sksurgerycore.transforms.matrix.construct_rigid_transformation(rot_m, trans_v)[source]

Construct a 4x4 rigid-body transformation from a 3x3 rotation matrix and a 3x1 vector as translation

Parameters:
  • rot_m – 3x3 rotation matrix, numpy array
  • trans_v – 3x1 vector as translation, numpy array
Returns:

rigid_transformation – 4x4 rigid transformation matrix,

numpy array

sksurgerycore.transforms.matrix.construct_rotm_from_euler(angle_a, angle_b, angle_c, sequence, is_in_radians=True)[source]

Construct a rotation matrix from a sequence of three Euler angles, to pre-multiply column vectors. In the case of tracking, the column vector is under the local coordinate system and the resulting vector is under the world (reference) coordinate system. The three elemental rotations represented by the Euler angles are about the INTRINSIC axes. They can also be interpreted to be about the EXTRINSIC axes, in the reverse order.

Parameters:
  • angle_a – first Euler angle, float, int allowed if in degrees
  • angle_b – second Euler angle, float, int allowed if in degrees
  • angle_c – third Euler angle, float, int allowed if in degrees
  • sequence – the sequence of axes the three elemental rotations are about, with respect to the intrinsic axes, string
  • is_in_radians – if the angles are in radians, default being True, bool
Returns:

rot_m – the 3x3 rotation matrix, numpy array

Raises:

TypeError if angles are not float or of difference types

Raises:

ValueError if sequence is not 3 letters long or contains letters other than x, y or z

sksurgerycore.transforms.matrix.construct_rx_matrix(angle, is_in_radians=True)[source]

Construct a rotation matrix for rotation around the x axis.

Parameters:angle – the angle to rotate radians, float
Returns:rot_x – the 3x3 rotation matrix constructed, numpy array
Raises:TypeError if angle is not float or int
sksurgerycore.transforms.matrix.construct_ry_matrix(angle, is_in_radians=True)[source]

Construct a rotation matrix for rotation around the y axis.

Parameters:
  • angle – the angle to rotate, float
  • is_in_radians – if angle is in radians, default being True, bool
Returns:

rot_y – the 3x3 rotation matrix constructed, numpy array

Raises:

TypeError if angle is not float or int

sksurgerycore.transforms.matrix.construct_rz_matrix(angle, is_in_radians=True)[source]

Construct a rotation matrix for rotation around the z axis.

Parameters:
  • angle – the angle to rotate, float
  • is_in_radians – if angle is in radians, default being True, bool
Returns:

rot_z – the 3x3 rotation matrix constructed, numpy array

Raises:

TypeError if angle is not float or int