Search in sources :

Example 16 with RotationMatrix3d

use of maspack.matrix.RotationMatrix3d in project artisynth_core by artisynth.

the class AffineTransformWidget method getTransformValue.

public AffineTransform3d getTransformValue() {
    RotationMatrix3d R = new RotationMatrix3d(getRotation());
    Vector3d scale = getScale();
    Vector3d shear = getShear();
    // XXX Note: if you return a RigidTransform3d, results in
    // an Illegal Argument Exception on "method.invoke(...)"
    // if (scale.x == 1 && scale.y == 1 && scale.z == 1 &&
    // shear.x == 0 && shear.y == 0 && shear.z == 0) {
    // RigidTransform3d RT = new RigidTransform3d();
    // RT.p.set (getTranslation());
    // RT.R.set (R);
    // return RT;
    // }
    // else {
    AffineTransform3d XT = new AffineTransform3d();
    XT.p.set(getTranslation());
    XT.setA(R, scale, shear);
    return XT;
// }
}
Also used : Vector3d(maspack.matrix.Vector3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 17 with RotationMatrix3d

use of maspack.matrix.RotationMatrix3d in project artisynth_core by artisynth.

the class AffineTransformWidget method main.

public static void main(String[] args) {
    JFrame frame = new JFrame("AffineTransformWidget Test");
    LabeledComponentPanel panel = new LabeledComponentPanel();
    AffineTransformWidget widget = new AffineTransformWidget("affineX", "TR");
    frame.getContentPane().add(panel);
    widget.unpackFields();
    AffineTransform3d X = new AffineTransform3d();
    RotationMatrix3d R = new RotationMatrix3d(1, 0, 0, Math.toRadians(45));
    Vector3d scale = new Vector3d(1, 2, 3);
    Vector3d shear = new Vector3d(0.2, 0.4, 0.6);
    // Vector3d scale = new Vector3d (1, 1, 1);
    // Vector3d shear = new Vector3d (0, 0, 0);
    X.setA(R, scale, shear);
    widget.setValue(X);
    widget.addValueChangeListener(new ValueChangeListener() {

        public void valueChange(ValueChangeEvent e) {
            AffineTransformWidget w = (AffineTransformWidget) e.getSource();
            System.out.println("new value:\n" + w.getTransformValue().toString("%10.6f"));
        }
    });
    panel.addWidget("translation", widget.getTranslationField());
    panel.addWidget("orientation", widget.getRotationField());
    panel.addWidget("scale", widget.getScaleField());
    panel.addWidget("shear", widget.getShearField());
    // panel.addWidget (widget);
    frame.pack();
    frame.setVisible(true);
}
Also used : JFrame(javax.swing.JFrame) Vector3d(maspack.matrix.Vector3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 18 with RotationMatrix3d

use of maspack.matrix.RotationMatrix3d in project artisynth_core by artisynth.

the class ViewerToolBar method updateIcons.

public void updateIcons() {
    if (myAxialViewMenuItems == null) {
        // has finished constructing
        return;
    }
    AxisAlignedRotation defaultView = myViewer.getDefaultAxialView();
    if (defaultView != myDefaultAxialView) {
        // default view has changed; rebuild the icon list
        myDefaultAxialView = defaultView;
        RotationMatrix3d RDefault = defaultView.getMatrix();
        for (AxialViewMenuItem item : myAxialViewMenuItems) {
            if (item != myCurrentViewMenuItem) {
                item.setRelativeAxialView(RDefault);
            }
        }
    }
    // now look for the current view in the list.
    AxisAlignedRotation currentView = myViewer.getAxialView();
    if (myCurrentViewMenuItem.getAxialView() != currentView) {
        myCurrentViewMenuItem.setAxialView(currentView);
        setAxialViewIcon(myCurrentViewMenuItem.getIcon());
    }
}
Also used : AxisAlignedRotation(maspack.matrix.AxisAlignedRotation) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Example 19 with RotationMatrix3d

use of maspack.matrix.RotationMatrix3d in project artisynth_core by artisynth.

the class RigidTransformWidget method updateInternalValue.

/**
 * Updates the internal representation of the value, updates any result
 * holders, and returns true if the new value differs from the old value.
 */
protected boolean updateInternalValue(Object value) {
    if (!valuesEqual(value, myValue)) {
        myTranslationField.maskValueChangeListeners(true);
        myRotationField.maskValueChangeListeners(true);
        if (value instanceof RigidTransform3d) {
            RigidTransform3d newX = (RigidTransform3d) value;
            if (myTranslationField.valueIsVoid() || !newX.p.equals(getTranslation())) {
                myTranslationField.setValue(newX.p);
            }
            RotationMatrix3d R = new RotationMatrix3d();
            if (!myRotationField.valueIsVoid()) {
                R.setAxisAngle(getRotation());
            }
            if (myRotationField.valueIsVoid() || !newX.R.equals(R)) {
                AxisAngle newAxisAngle = new AxisAngle();
                newX.R.getAxisAngle(newAxisAngle);
                myRotationField.setValue(newAxisAngle);
            }
            value = new RigidTransform3d(newX);
        } else if (value == Property.VoidValue) {
            myTranslationField.setValue(Property.VoidValue);
            myRotationField.setValue(Property.VoidValue);
        }
        myTranslationField.maskValueChangeListeners(false);
        myRotationField.maskValueChangeListeners(false);
        myValue = value;
        return true;
    } else {
        return false;
    }
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) AxisAngle(maspack.matrix.AxisAngle) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Example 20 with RotationMatrix3d

use of maspack.matrix.RotationMatrix3d in project artisynth_core by artisynth.

the class Main method createViewerFrame.

public GLViewerFrame createViewerFrame() {
    GLViewerFrame frame = new GLViewerFrame(myViewer, PROJECT_NAME, 400, 400);
    GLViewer viewer = frame.getViewer();
    // ViewerToolBar toolBar = new ViewerToolBar(viewer, this);
    AxisAngle REW = getDefaultViewOrientation(getRootModel());
    myViewerManager.addViewer(viewer);
    ViewerToolBar toolBar = new ViewerToolBar(viewer, /*addGridPanel=*/
    true);
    frame.getContentPane().add(toolBar, BorderLayout.PAGE_START);
    viewer.setDefaultAxialView(AxisAlignedRotation.getNearest(new RotationMatrix3d(REW)));
    initializeViewer(viewer, REW);
    frame.setVisible(true);
    return frame;
}
Also used : ViewerToolBar(maspack.widgets.ViewerToolBar) GLViewer(maspack.render.GL.GLViewer) AxisAngle(maspack.matrix.AxisAngle) GLViewerFrame(maspack.render.GL.GLViewerFrame) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Aggregations

RotationMatrix3d (maspack.matrix.RotationMatrix3d)66 Vector3d (maspack.matrix.Vector3d)27 RigidTransform3d (maspack.matrix.RigidTransform3d)15 Point3d (maspack.matrix.Point3d)14 Matrix3d (maspack.matrix.Matrix3d)13 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)9 AxisAngle (maspack.matrix.AxisAngle)7 Matrix6d (maspack.matrix.Matrix6d)6 Point (artisynth.core.mechmodels.Point)4 AffineTransform3d (maspack.matrix.AffineTransform3d)4 SVDecomposition3d (maspack.matrix.SVDecomposition3d)4 VectorNd (maspack.matrix.VectorNd)3 InternalErrorException (maspack.util.InternalErrorException)3 FrameMaterial (artisynth.core.materials.FrameMaterial)2 RotAxisFrameMaterial (artisynth.core.materials.RotAxisFrameMaterial)2 JFrame (javax.swing.JFrame)2 AxisAlignedRotation (maspack.matrix.AxisAlignedRotation)2 Matrix6dBlock (maspack.matrix.Matrix6dBlock)2 Matrix6x3Block (maspack.matrix.Matrix6x3Block)2 Plane (maspack.matrix.Plane)2