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;
// }
}
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);
}
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());
}
}
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;
}
}
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;
}
Aggregations