Search in sources :

Example 16 with AffineTransform3d

use of maspack.matrix.AffineTransform3d 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 AffineTransform3d

use of maspack.matrix.AffineTransform3d 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 AffineTransform3d

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

the class MFreeElement3d method renderWidget.

public void renderWidget(Renderer renderer, double size, RenderProps props, int flags) {
    if (myBoundaryMesh != null && size > 0) {
        if (!renderMeshValid) {
            // for (Vertex3d vtx : myBoundaryMesh.getVertices()) {
            // if (vtx instanceof MFreeVertex3d) {
            // ((MFreeVertex3d)vtx).updatePosAndVelState();
            // }
            // }
            renderMeshValid = true;
        }
        Point3d cntr = new Point3d();
        AffineTransform3d trans = new AffineTransform3d();
        myBoundaryMesh.computeCentroid(cntr);
        cntr.scale(1 - size);
        trans.setTranslation(cntr);
        trans.applyScaling(size, size, size);
        renderer.pushModelMatrix();
        renderer.mulModelMatrix(trans);
        if (isSelected()) {
            flags |= Renderer.HIGHLIGHT;
        }
        myBoundaryMesh.render(renderer, props, flags);
        renderer.popModelMatrix();
    }
}
Also used : Point3d(maspack.matrix.Point3d) IntegrationPoint3d(artisynth.core.femmodels.IntegrationPoint3d) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 19 with AffineTransform3d

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

the class RigidBody method createEllipsoid.

/**
 * Creates an ellipsoidal RigidBody with a prescribed uniform density.
 * The ellipsoid is centered on the origin.
 *
 * @param bodyName name of the RigidBody
 * @param a semi-axis length in the x direction
 * @param b semi-axis length in the y direction
 * @param c semi-axis length in the z direction
 * @param density density of the body
 * @param nslices number of slices used in creating the mesh
 * @return ellipsoidal rigid body
 */
public static RigidBody createEllipsoid(String bodyName, double a, double b, double c, double density, int nslices) {
    RigidBody body = new RigidBody(bodyName);
    PolygonalMesh mesh = MeshFactory.createSphere(1.0, nslices);
    AffineTransform3d XScale = new AffineTransform3d();
    XScale.applyScaling(a, b, c);
    mesh.transform(XScale);
    body.setMesh(mesh, null);
    double mass = 4 / 3.0 * Math.PI * a * b * c * density;
    body.setInertia(SpatialInertia.createEllipsoidInertia(mass, a, b, c));
    return body;
}
Also used : PolygonalMesh(maspack.geometry.PolygonalMesh) AffineTransform3d(maspack.matrix.AffineTransform3d)

Example 20 with AffineTransform3d

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

the class AffineNumericInputProbe method getTransform.

public AffineTransform3d getTransform() {
    Matrix3d Ar = new Matrix3d();
    R.getSubMatrix(0, 0, Ar);
    // not very
    Vector3d At = new Vector3d(t.get(0), t.get(1), t.get(2));
    return new AffineTransform3d(Ar, At);
}
Also used : Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d) AffineTransform3d(maspack.matrix.AffineTransform3d)

Aggregations

AffineTransform3d (maspack.matrix.AffineTransform3d)46 Vector3d (maspack.matrix.Vector3d)14 RigidTransform3d (maspack.matrix.RigidTransform3d)13 Point3d (maspack.matrix.Point3d)7 PolygonalMesh (maspack.geometry.PolygonalMesh)5 AxisAngle (maspack.matrix.AxisAngle)5 Matrix3d (maspack.matrix.Matrix3d)4 RotationMatrix3d (maspack.matrix.RotationMatrix3d)4 InstanceTransformType (maspack.render.RenderInstances.InstanceTransformType)4 RenderProps (maspack.render.RenderProps)4 RigidBody (artisynth.core.mechmodels.RigidBody)3 Point (java.awt.Point)3 IOException (java.io.IOException)3 RenderObject (maspack.render.RenderObject)3 CollisionManager (artisynth.core.mechmodels.CollisionManager)2 MechModel (artisynth.core.mechmodels.MechModel)2 File (java.io.File)2 ByteBuffer (java.nio.ByteBuffer)2 ArrayList (java.util.ArrayList)2 Vertex3d (maspack.geometry.Vertex3d)2