def rotate(self, rotation: List[float]) -> None: """Rotates a transformation matrix. :param rotation: The x, y, z rotation to perform (in radians). """ m = vrep.simGetObjectMatrix(self._handle, -1) x_axis = [m[0], m[4], m[8]] y_axis = [m[1], m[5], m[9]] z_axis = [m[2], m[6], m[10]] axis_pos = vrep.simGetObjectPosition(self._handle, -1) m = vrep.simRotateAroundAxis(m, z_axis, axis_pos, rotation[2]) m = vrep.simRotateAroundAxis(m, y_axis, axis_pos, rotation[1]) m = vrep.simRotateAroundAxis(m, x_axis, axis_pos, rotation[0]) vrep.simSetObjectMatrix(self._handle, -1, m)
def set_matrix(self, matrix: List[float], relative_to=None) -> None: """Sets the transformation matrix of this object. :param relative_to: Indicates relative to which reference frame the matrix is specified. Specify None to set the absolute transformation matrix, or an Object relative to whose reference frame the transformation matrix is specified. :param matrix: A list of 12 float values (the last row of the 4x4 matrix (0,0,0,1) is not needed). The x-axis of the orientation component is (m[0], m[4], m[8]) The y-axis of the orientation component is (m[1], m[5], m[9]) The z-axis of the orientation component is (m[2], m[6], m[10]) The translation component is (m[3], m[7], m[11]) """ relto = -1 if relative_to is None else relative_to.get_handle() vrep.simSetObjectMatrix(self._handle, relto, matrix)