Search in sources :

Example 26 with AxisAngle

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

the class FemCollisions method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    // Reduce step size to better resolve collisions
    setMaxStepSize(0.0002);
    // Create and add main MechModel
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // -------------------------------------------------------------
    // BEAM
    // -------------------------------------------------------------
    // Create FEM beam
    FemModel3d beam = new FemModel3d("beam");
    mech.addModel(beam);
    // widths
    double[] size = { 0.003, 0.0015, 0.0015 };
    // resolution
    int[] res = { 4, 2, 2 };
    FemFactory.createGrid(beam, FemElementType.Hex, size[0], size[1], size[2], res[0], res[1], res[2]);
    // Set properties
    beam.setDensity(1000);
    beam.setMaterial(new LinearMaterial(300, 0.33));
    // -------------------------------------------------------------
    // ELLIPSOID
    // -------------------------------------------------------------
    // Create FEM ellipsoid
    FemModel3d ellipsoid = new FemModel3d("ellipsoid");
    mech.addModel(ellipsoid);
    // radii (z, x, y)
    double[] radii = { 0.002, 0.001, 0.001 };
    // resolution (theta, phi, r)
    int[] eres = { 16, 4, 3 };
    FemFactory.createEllipsoid(ellipsoid, radii[0], radii[1], radii[2], eres[0], eres[1], eres[2]);
    // Set properties
    ellipsoid.setDensity(1000);
    ellipsoid.setMaterial(new LinearMaterial(300, 0.33));
    // Transform: rotate 90 degrees about X-Axis
    // translate up by 0.003
    RigidTransform3d trans = new RigidTransform3d();
    trans.setRotation(new AxisAngle(1, 0, 0, Math.PI / 2));
    trans.setTranslation(new Vector3d(0, 0.0005, 0.003));
    ellipsoid.transformGeometry(trans);
    // -------------------------------------------------------------
    // BLOCK WITH EMBEDDED SPHERE
    // -------------------------------------------------------------
    // Create FEM block
    FemModel3d block = new FemModel3d("block");
    mech.addModel(block);
    FemFactory.createHexGrid(block, 0.002, 0.002, 0.002, 3, 3, 3);
    // Set properties
    block.setDensity(1000);
    block.setMaterial(new LinearMaterial(300, 0.33));
    // Create embedded sphere
    double r = 0.0008;
    // level of refinement
    int ref = 2;
    PolygonalMesh sphere = MeshFactory.createOctahedralSphere(r, ref);
    FemMeshComp embeddedSphere = block.addMesh("embedded", sphere);
    // Transform: rotate 90 degrees about X-Axis
    // translate left by 0.003
    trans = new RigidTransform3d();
    trans.setTranslation(new Vector3d(0, 0.003, 0));
    block.transformGeometry(trans);
    // -------------------------------------------------------------
    // TABLE AND COLLISIONS
    // -------------------------------------------------------------
    RigidBody table = RigidBody.createBox("table", 0.005, 0.0075, 0.0008, 0);
    table.setDynamic(false);
    table.setPose(new RigidTransform3d(new Vector3d(0, 0.0015, -0.002), AxisAngle.IDENTITY));
    mech.addRigidBody(table);
    // Set up collisions
    mech.setCollisionBehavior(ellipsoid, beam, true, 0.1);
    mech.setCollisionBehavior(ellipsoid, table, true, 0.1);
    mech.setCollisionBehavior(embeddedSphere, table, true, 0.1);
    mech.setCollisionBehavior(ellipsoid, embeddedSphere, true, 0.1);
    mech.setCollisionBehavior(table, beam, true, 0.1);
    // -------------------------------------------------------------
    // RENDER PROPERTIES
    // -------------------------------------------------------------
    // Draw beam element widgets
    beam.setElementWidgetSize(0.8);
    RenderProps.setLineWidth(beam.getElements(), 0);
    // Make beam blue, and give it a transparent surface
    RenderProps.setFaceColor(beam, Color.BLUE);
    beam.setSurfaceRendering(SurfaceRender.Shaded);
    RenderProps.setAlpha(beam.getMeshComp("surface"), 0.4);
    // Make the ellipsoid red
    RenderProps.setFaceColor(ellipsoid, Color.RED);
    RenderProps.setLineColor(ellipsoid, Color.RED.darker());
    ellipsoid.setSurfaceRendering(SurfaceRender.Shaded);
    // Make the block green
    RenderProps.setFaceColor(block, Color.GREEN);
    RenderProps.setLineColor(block, Color.GREEN.darker());
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) FemModel3d(artisynth.core.femmodels.FemModel3d) FemMeshComp(artisynth.core.femmodels.FemMeshComp) LinearMaterial(artisynth.core.materials.LinearMaterial) PolygonalMesh(maspack.geometry.PolygonalMesh) MechModel(artisynth.core.mechmodels.MechModel) AxisAngle(maspack.matrix.AxisAngle) Vector3d(maspack.matrix.Vector3d) RigidBody(artisynth.core.mechmodels.RigidBody)

Example 27 with AxisAngle

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

the class FemModel3dAgent method createLocationPanel.

private void createLocationPanel() {
    positionField = new VectorField("position", 3);
    positionField.setStretchable(true);
    positionField.addValueChangeListener(this);
    orientationField = new AxisAngleField("orientiation", new AxisAngle());
    orientationField.setStretchable(true);
    orientationField.addValueChangeListener(this);
    LabeledComponentPanel locationPanel = new LabeledComponentPanel();
    locationPanel.addWidget(positionField);
    locationPanel.addWidget(orientationField);
    addWidget(locationPanel);
    locationPanel.setBorder(GuiUtils.createTitledPanelBorder("Location"));
}
Also used : AxisAngle(maspack.matrix.AxisAngle) VectorField(maspack.widgets.VectorField) AxisAngleField(maspack.widgets.AxisAngleField) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel)

Example 28 with AxisAngle

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

the class RigidBodyAgent method createLocationPanel.

private void createLocationPanel() {
    positionField = new VectorField("position", 3);
    positionField.setStretchable(true);
    positionField.addValueChangeListener(this);
    orientationField = new AxisAngleField("orientiation", new AxisAngle());
    orientationField.setStretchable(true);
    orientationField.addValueChangeListener(this);
    LabeledComponentPanel locationPanel = new LabeledComponentPanel();
    locationPanel.addWidget(positionField);
    locationPanel.addWidget(orientationField);
    addWidget(locationPanel);
    locationPanel.setBorder(GuiUtils.createTitledPanelBorder("Location"));
}
Also used : AxisAngle(maspack.matrix.AxisAngle) VectorField(maspack.widgets.VectorField) AxisAngleField(maspack.widgets.AxisAngleField) LabeledComponentPanel(maspack.widgets.LabeledComponentPanel)

Example 29 with AxisAngle

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

the class GridPlane method getOrientation.

/**
 * Gets the orientation of the display
 */
public AxisAngle getOrientation() {
    AxisAngle axisAng = new AxisAngle();
    XGridToWorld.R.getAxisAngle(axisAng);
    return axisAng;
}
Also used : AxisAngle(maspack.matrix.AxisAngle)

Example 30 with AxisAngle

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

the class TextComponent3d method setDefaults.

protected void setDefaults() {
    myFont = new Font(defaultFontName, 0, defaultFontSize);
    myRenderProps = createDefaultRenderProps();
    hAlignment = defaultHAlignment;
    vAlignment = defaultVAlignment;
    myTextSize = defaultTextSize;
    myFontSize = defaultFontSize;
    myText = "";
    myPos = new Point3d();
    myOrientation = new AxisAngle();
    followEye = true;
}
Also used : AxisAngle(maspack.matrix.AxisAngle) Point3d(maspack.matrix.Point3d) Font(java.awt.Font)

Aggregations

AxisAngle (maspack.matrix.AxisAngle)38 Vector3d (maspack.matrix.Vector3d)19 RigidTransform3d (maspack.matrix.RigidTransform3d)18 PolygonalMesh (maspack.geometry.PolygonalMesh)8 Point3d (maspack.matrix.Point3d)7 RotationMatrix3d (maspack.matrix.RotationMatrix3d)7 AffineTransform3d (maspack.matrix.AffineTransform3d)5 RigidBody (artisynth.core.mechmodels.RigidBody)4 MechModel (artisynth.core.mechmodels.MechModel)3 Font (java.awt.Font)3 File (java.io.File)3 IOException (java.io.IOException)3 GLViewer (maspack.render.GL.GLViewer)3 FemNode3d (artisynth.core.femmodels.FemNode3d)2 CollisionManager (artisynth.core.mechmodels.CollisionManager)2 HashMap (java.util.HashMap)2 JFrame (javax.swing.JFrame)2 RenderProps (maspack.render.RenderProps)2 ReaderTokenizer (maspack.util.ReaderTokenizer)2 AxisAngleField (maspack.widgets.AxisAngleField)2