Ejemplo n.º 1
0
    def from_tree(cls, tree, ctx):
        """
        Converts basic types representing YAML trees into custom types.

        Parameters
        ----------
        tree :
            An instance of a basic Python type (possibly nested) that
            corresponds to a YAML subtree.
        ctx :
            An instance of the 'AsdfFile' object that is being constructed.

        Returns
        -------
        Dimension :
            An instance of the 'Dimension' type.

        """
        if "quaternions" in tree:
            return WXRotation.from_quat(tree["quaternions"])
        elif "matrix" in tree:
            return WXRotation.from_matrix(tree["matrix"])
        elif "rotvec" in tree:
            return WXRotation.from_rotvec(tree["rotvec"])
        elif "angles" in tree:
            if "degree" in str(tree["angles"].units):
                angles = tree["angles"].to("degree").magnitude
                degrees = True
            else:
                angles = tree["angles"].to("rad").magnitude
                degrees = False
            return WXRotation.from_euler(seq=tree["sequence"],
                                         angles=angles,
                                         degrees=degrees)
Ejemplo n.º 2
0
from weldx.tests._helpers import get_test_name
from weldx.transformations import WXRotation

# WXRotation ---------------------------------------------------------------------
_base_rotation = Rotation.from_euler(seq="xyz",
                                     angles=[[10, 20, 60], [25, 50, 175]],
                                     degrees=True)


@pytest.mark.parametrize(
    "inputs",
    [
        _base_rotation,
        WXRotation.from_quat(_base_rotation.as_quat()),
        WXRotation.from_matrix(_base_rotation.as_matrix()),
        WXRotation.from_rotvec(_base_rotation.as_rotvec()),
        WXRotation.from_euler(seq="xyz", angles=[10, 20, 60], degrees=True),
        WXRotation.from_euler(
            seq="xyz", angles=[0.2, 1.3, 3.14], degrees=False),
        WXRotation.from_euler(seq="xyz", angles=Q_([10, 20, 60], "degree")),
        WXRotation.from_euler(seq="xyz", angles=Q_([0.2, 1.3, 3.14], "rad")),
        WXRotation.from_euler(seq="xyz", angles=Q_([0.2, 1.3, 3.14], "")),
        WXRotation.from_euler(seq="XYZ", angles=[10, 20, 60], degrees=True),
        WXRotation.from_euler(seq="y", angles=[10, 60, 40, 90], degrees=True),
        WXRotation.from_euler(seq="Z", angles=[10, 60, 40, 90], degrees=True),
        WXRotation.from_euler(seq="xy",
                              angles=[[10, 10], [60, 60], [40, 40], [70, 75]],
                              degrees=True),
        WXRotation.from_euler(
            seq="xy",
            angles=Q_([[10, 10], [60, 60], [40, 40], [70, 75]], "degree")),