Пример #1
0
    def decompose(self):
        """Decomposes the ``Transformation`` into ``Scale``, ``Shear``, \
            ``Rotation``, ``Translation`` and ``Perspective``.

        Example:
            >>> trans1 = [1, 2, 3]
            >>> angle1 = [-2.142, 1.141, -0.142]
            >>> scale1 = [0.123, 2, 0.5]
            >>> T1 = Translation(trans1)
            >>> R1 = Rotation.from_euler_angles(angle1)
            >>> S1 = Scale(scale1)
            >>> M = (T1 * R1) * S1
            >>> Sc, Sh, R, T, P = M.decompose()
            >>> S1 == Sc
            True
            >>> R1 == R
            True
            >>> T1 == T
            True
        """
        from compas.geometry.xforms import Scale
        from compas.geometry.xforms import Shear
        from compas.geometry.xforms import Rotation
        from compas.geometry.xforms import Translation
        from compas.geometry.xforms import Projection

        sc, sh, a, t, p = decompose_matrix(self.matrix)

        Sc = Scale(sc)
        Sh = Shear.from_entries(sh)
        R = Rotation.from_euler_angles(a, static=True, axes='xyz')
        T = Translation(t)
        P = Projection.from_entries(p)

        return Sc, Sh, R, T, P
Пример #2
0
    def calculate_continous_transformation(self, position):
        """Returns a transformation of a continous joint.

        A continous joint rotates about the axis and has no upper and lower
        limits.

        Args:
            position (float): the angle in radians
        """
        return Rotation.from_axis_and_angle(self.axis.vector, position, self.origin.point)
Пример #3
0
    def get_forward_transformations(self, configuration):
        """Calculate the transformations according to the configuration.

        Args:
            configuration (:class:`Configuration`): The robot's configuration.

        Returns:
            transformations (:obj:`list` of :class:`Transformation`): The
                transformations for each link.
        """
        q0, q1, q2, q3, q4, q5 = configuration.joint_values
        j0, j1, j2, j3, j4, j5 = self.j0, self.j1, self.j2, self.j3, self.j4, self.j5

        T0 = Rotation.from_axis_and_angle(subtract_vectors(j0[1], j0[0]), q0, j0[1])
        j1 = transform_points(j1, T0)
        T1 = Rotation.from_axis_and_angle(subtract_vectors(j1[1], j1[0]), q1, j1[1]) * T0
        j2 = transform_points(j2, T1)
        T2 = Rotation.from_axis_and_angle(subtract_vectors(j2[1], j2[0]), q2, j2[1]) * T1
        j3 = transform_points(j3, T2)
        T3 = Rotation.from_axis_and_angle(subtract_vectors(j3[1], j3[0]), q3, j3[1]) * T2
        j4 = transform_points(j4, T3)
        T4 = Rotation.from_axis_and_angle(subtract_vectors(j4[1], j4[0]), q4, j4[1]) * T3
        j5 = transform_points(j5, T4)
        T5 = Rotation.from_axis_and_angle(subtract_vectors(j5[1], j5[0]), q5, j5[1]) * T4

        # now apply the transformation to the base
        T0 = self.transformation_RCS_WCS * T0
        T1 = self.transformation_RCS_WCS * T1
        T2 = self.transformation_RCS_WCS * T2
        T3 = self.transformation_RCS_WCS * T3
        T4 = self.transformation_RCS_WCS * T4
        T5 = self.transformation_RCS_WCS * T5

        return T0, T1, T2, T3, T4, T5
Пример #4
0
        True

        """
        frame = self.copy()
        frame.transform(transformation)
        return frame


# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    R = Rotation.from_frame(f1)
    f2 = Frame.from_rotation(R, point=f1.point)
    print(f1 == f2)

    print(f2)

    f1 = Frame([1, 1, 1], [0.68, 0.68, 0.27], [-0.67, 0.73, -0.15])
    T = Transformation.from_frame(f1)
    f2 = Frame.from_transformation(T)
    print(f1 == f2)

    ea1 = [0.5, 0.4, 0.8]
    M = matrix_from_euler_angles(ea1)
    f = Frame.from_matrix(M)
    ea2 = f.euler_angles()
    print(allclose(ea1, ea2))