Example #1
0
 def transformation_matrix(self, matrix):
     R, S = qrp(matrix)
     s = numpy.diag(S)
     if not numpy.allclose(S, numpy.diag(s)):
         raise LinAlgError('Array must be diagonal')
     self.rotation_matrix = R
     self.scale = s
Example #2
0
def alt_transformation_matrix_to_implicit(
    matrix: numpy.ndarray, form: str,
) -> Tuple[numpy.ndarray, float, float]:
    """
    Return an alternative description of the implicit parameters given a
    transformation matrix. This implementation is provided for backwards
    compatibility. Do not use for new design.

    Parameters
    ----------
    matrix : ndarray
        The transformation matrix.
    form : {"RSU", "RSL"}
        Whether the matrix is of the form `RSU` or `RSL`.

    Returns
    -------
    scale : (sx, sy) as ndarray
        x, y scale factors.
    rotation : float
        Roation angle in counter-clockwise direction as radians.
    shear : float
        Shear factor.

    """
    if form == "RSU":
        R, SU = qrp(matrix)
        scale = numpy.diag(SU)
        rotation = _rotation_matrix_to_angle(R)
        shear = SU[0, 1] / SU[0, 0]
    elif form == "RSL":
        R, SL = qlp(matrix)
        scale = numpy.diag(SL)
        rotation = _rotation_matrix_to_angle(R)
        shear = SL[1, 0] / SL[1, 1]
    else:
        raise ValueError("`form` must be either 'RSU' or 'RSL'")
    return scale, rotation, shear
Example #3
0
 def transformation_matrix(self, matrix):
     R, S = qrp(matrix)
     self.rotation_matrix = R
     self.scale = numpy.diag(S)
     self.shear = S[0, 1] / S[0, 0]