Search in sources :

Example 1 with AxialSpring

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

the class MultiSpringTest method addMixedUpSprings.

protected void addMixedUpSprings(MechModel mech) {
    Particle p = new Particle(1, new Point3d(0, 0, 0.1));
    mech.addParticle(p);
    Particle lastp = p;
    for (int i = 0; i < 20; ++i) {
        p = new Particle(1, new Point3d((i + 1) * 0.1, 2 * (i % 2 - 0.5) * 0.1, 0.1));
        mech.addParticle(p);
        AxialSpring ax = new AxialSpring("spring mixed " + i);
        if (i % 2 == 0) {
            ax.setPoints(lastp, p);
        } else {
            ax.setPoints(p, lastp);
        }
        mech.addAxialSpring(ax);
        lastp = p;
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 2 with AxialSpring

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

the class MultiSpringTest method addSeparatedSprings.

protected void addSeparatedSprings(MechModel mech) {
    for (int i = 0; i < 10; ++i) {
        Particle p1 = new Particle(1, new Point3d((2 * i) * 0.1, 2 * (i % 2 - 0.5) * 0.1, -0.1));
        Particle p2 = new Particle(1, new Point3d((2 * i + 1) * 0.1, -2 * (i % 2 - 0.5) * 0.1, -0.1));
        mech.addParticle(p1);
        mech.addParticle(p2);
        AxialSpring ax = new AxialSpring("spring detached " + i);
        if (i % 2 == 0) {
            ax.setPoints(p1, p2);
        } else {
            ax.setPoints(p2, p1);
        }
        mech.addAxialSpring(ax);
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 3 with AxialSpring

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

the class MultiSpringTest method addSprings.

protected void addSprings(MechModel mech) {
    Particle p = new Particle(1, new Point3d(0, 0, 0));
    mech.addParticle(p);
    Particle lastp = p;
    for (int i = 0; i < 20; ++i) {
        p = new Particle(1, new Point3d((i + 1) * 0.1, 2 * (i % 2 - 0.5) * 0.1, 0));
        mech.addParticle(p);
        AxialSpring ax = new AxialSpring("spring " + i);
        ax.setPoints(lastp, p);
        mech.addAxialSpring(ax);
        lastp = p;
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 4 with AxialSpring

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

the class MultiSpringTest method addVerticalSprings.

protected void addVerticalSprings(MechModel mech) {
    for (int i = 0; i < 5; ++i) {
        Particle p1 = new Particle(0.1, i * 0.1, 0, 0.1);
        Particle p2 = new Particle(0.1, i * 0.1 + 0.00001 * i, 0, 0.0);
        mech.addParticle(p1);
        mech.addParticle(p2);
        AxialSpring as = new AxialSpring("vertical " + i);
        if (i % 2 == 0) {
            as.setPoints(p1, p2);
        } else {
            as.setPoints(p2, p1);
        }
        mech.addAxialSpring(as);
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 5 with AxialSpring

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

the class MultiSpringTest method build.

@Override
public void build(String[] args) throws IOException {
    super.build(args);
    MechModel mech = new MechModel("mech");
    addModel(mech);
    // addSprings(mech);
    // addMixedUpSprings(mech);
    // addSeparatedSprings(mech);
    // addSpringMesh(mech);
    addVerticalSprings(mech);
    // clear render props
    for (AxialSpring s : mech.axialSprings()) {
        s.setRenderProps(null);
    }
    RenderProps.setLineStyle(mech, LineStyle.CYLINDER);
    RenderProps.setLineRadius(mech, 0.02);
}
Also used : MechModel(artisynth.core.mechmodels.MechModel) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Aggregations

AxialSpring (artisynth.core.mechmodels.AxialSpring)20 Particle (artisynth.core.mechmodels.Particle)10 Muscle (artisynth.core.mechmodels.Muscle)8 Point3d (maspack.matrix.Point3d)8 RigidBody (artisynth.core.mechmodels.RigidBody)5 FrameMarker (artisynth.core.mechmodels.FrameMarker)4 MechModel (artisynth.core.mechmodels.MechModel)4 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)3 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)3 Color (java.awt.Color)3 RenderProps (maspack.render.RenderProps)3 ForceTarget (artisynth.core.inverse.ForceTarget)2 ForceTargetTerm (artisynth.core.inverse.ForceTargetTerm)2 TrackingController (artisynth.core.inverse.TrackingController)2 Point (artisynth.core.mechmodels.Point)2 WayPoint (artisynth.core.probes.WayPoint)2 RigidTransform3d (maspack.matrix.RigidTransform3d)2 FemElement (artisynth.core.femmodels.FemElement)1 FemMarker (artisynth.core.femmodels.FemMarker)1 FemNode (artisynth.core.femmodels.FemNode)1