Search in sources :

Example 1 with PointForce

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

the class PointForceDemo method build.

public void build(String[] args) throws IOException {
    super.build(args);
    if (myMechMod == null || myHand2 == null) {
        System.err.println("null mechmodel of hand2");
        return;
    }
    FrameMarker m = new FrameMarker("ee");
    myMechMod.addFrameMarker(m, myHand2, new Point3d(0, 0, myHand2.getPose().p.z / 3));
    RenderProps.setPointStyle(m, Renderer.PointStyle.SPHERE);
    RenderProps.setPointColor(m, Color.RED);
    RenderProps.setPointRadius(m, 0.01);
    double magnitude = 0.001;
    Vector3d fext = new Vector3d(-1, 0, 0);
    // m.setExternalForce (fext);
    PointForce pf = new PointForce(fext, m);
    pf.setMagnitude(magnitude);
    // mm spatial units
    pf.setForceScaling(1000);
    pf.setAxisLength(0.1);
    RenderProps.setLineStyle(pf, LineStyle.CYLINDER);
    RenderProps.setLineRadius(pf, pf.getAxisLength() / 20);
    RenderProps.setLineColor(pf, Color.GREEN);
    myMechMod.addForceEffector(pf);
}
Also used : PointForce(artisynth.core.mechmodels.PointForce) FrameMarker(artisynth.core.mechmodels.FrameMarker) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d)

Aggregations

FrameMarker (artisynth.core.mechmodels.FrameMarker)1 PointForce (artisynth.core.mechmodels.PointForce)1 Point3d (maspack.matrix.Point3d)1 Vector3d (maspack.matrix.Vector3d)1