Search in sources :

Example 1 with SegmentedPlanarConnector

use of artisynth.core.mechmodels.SegmentedPlanarConnector in project artisynth_core by artisynth.

the class SegmentedPlaneDemo method build.

public void build(String[] args) {
    // set up the mechmodel
    MechModel mechMod = new MechModel("mechMod");
    mechMod.setGravity(0, 0, -9.8);
    mechMod.setFrameDamping(1.0);
    mechMod.setRotaryDamping(4.0);
    mechMod.setIntegrator(MechSystemSolver.Integrator.BackwardEuler);
    // set up the rigid body and the plane constraint
    double lenx = 10;
    double leny = 5;
    double lenz = 3;
    RigidBody box = new RigidBody("box");
    RigidTransform3d XBoxToWorld = new RigidTransform3d();
    box.setInertia(SpatialInertia.createBoxInertia(10, lenx, leny, lenz));
    PolygonalMesh mesh = MeshFactory.createBox(lenx, leny, lenz);
    box.setMesh(mesh, /* fileName= */
    null);
    XBoxToWorld.p.set(0, 0, lenz / 2);
    box.setPose(XBoxToWorld);
    mechMod.addRigidBody(box);
    // FrameMarker mkr = new FrameMarker (box, -5, 2.5, 1.5);
    // mechMod.addFrameMarker (mkr);
    // RenderProps props = mkr.createRenderProps();
    // props.setPointColor (Color.blue);
    // props.setPointStyle (RenderProps.PointStyle.SPHERE);
    // props.setPointRadius (0.25);
    // mkr.setRenderProps (props);
    RigidTransform3d XPlanesToWorld = new RigidTransform3d();
    // XPlanesToWorld.R.setAxisAngle(0,1,0,Math.PI);
    SegmentedPlanarConnector segPlanes = new SegmentedPlanarConnector(box, new Vector3d(-5, 2.5, 1.5), XPlanesToWorld, new double[] { -6, 4, -3, 1, -1, 0, 1, 0, 3, 1, 6, 4 });
    segPlanes.setUnilateral(true);
    segPlanes.setPlaneSize(10);
    RenderProps props = segPlanes.createRenderProps();
    props.setPointColor(Color.blue);
    props.setPointStyle(PointStyle.SPHERE);
    props.setPointRadius(0.25);
    segPlanes.setRenderProps(props);
    // mechMod.addRigidBody (box);
    mechMod.addBodyConnector(segPlanes);
    addModel(mechMod);
    addControlPanel(mechMod);
// AffineTransform3d X = new AffineTransform3d ();
// X.applyScaling (1, 1, 2);
// mechMod.transformGeometry (X);
// RigidTransform3d X = new RigidTransform3d (0, 0, 1.5);
// box.transformGeometry (X);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) RigidBody(artisynth.core.mechmodels.RigidBody) SegmentedPlanarConnector(artisynth.core.mechmodels.SegmentedPlanarConnector)

Aggregations

MechModel (artisynth.core.mechmodels.MechModel)1 RigidBody (artisynth.core.mechmodels.RigidBody)1 SegmentedPlanarConnector (artisynth.core.mechmodels.SegmentedPlanarConnector)1