示例#1
0
def test_decompose_matrix(R, T):
    assert decompose_matrix(R.matrix) == ([1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                          [2.035405699485789, 0.0,
                                           0.0], [0.0, 0.0,
                                                  0.0], [0.0, 0.0, 0.0, 1.0])
    assert decompose_matrix(T.matrix) == ([1.0, 1.0, 1.0], [0.0, 0.0, 0.0],
                                          [0.0, -0.0,
                                           0.0], [1.0, 2.0,
                                                  3.0], [0.0, 0.0, 0.0, 1.0])
示例#2
0
    def from_matrix(cls, matrix):
        """Construct a frame from a matrix.

        Parameters
        ----------
        matrix : list of list of float
            The 4x4 transformation matrix in row-major order.

        Returns
        -------
        :class:`compas.geometry.Frame`
            The constructed frame.

        Examples
        --------
        >>> from compas.geometry import matrix_from_euler_angles
        >>> ea1 = [0.5, 0.4, 0.8]
        >>> M = matrix_from_euler_angles(ea1)
        >>> f = Frame.from_matrix(M)
        >>> ea2 = f.euler_angles()
        >>> allclose(ea1, ea2)
        True
        """
        _, _, angles, point, _ = decompose_matrix(matrix)
        R = matrix_from_euler_angles(angles, static=True, axes='xyz')
        xaxis, yaxis = basis_vectors_from_matrix(R)
        return cls(point, xaxis, yaxis)