Search in sources :

Example 11 with Particle

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

the class PointModel method add1dMuscles.

public void add1dMuscles() {
    boolean[] dyn = new boolean[] { false, true, false };
    int[] x = new int[] { -1, 0, 1 };
    // boolean[] dyn = new boolean[]{false,true, true, true,false};
    // int[] x = new int[]{-2,-1,0,1,2};
    // double eps = 1e-4;
    ArrayList<Point> pts = new ArrayList<Point>(x.length);
    for (int i = 0; i < x.length; i++) {
        Point3d pnt = new Point3d(x[i], 0, 0);
        // pnt.normalize();
        pnt.scale(len);
        Particle pt = new Particle(mass, pnt);
        pt.setPointDamping(pointDamping);
        pt.setDynamic(dyn[i]);
        model.addParticle(pt);
        pts.add(pt);
        if (x[i] == 0) {
        // center = pt;
        }
    }
    for (int i = 1; i < pts.size(); i++) {
        AxialSpring m;
        Point p0 = pts.get(i - 1);
        Point p1 = pts.get(i);
        // if (p0==center || p1==center)
        // m = addAxialSpring(p0, p1);
        // else
        m = addMuscle(p0, p1);
        m.setName("m" + Integer.toString(m.getNumber()));
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) ArrayList(java.util.ArrayList) Point(artisynth.core.mechmodels.Point) Point(artisynth.core.mechmodels.Point) SphericalJoint(artisynth.core.mechmodels.SphericalJoint) AxialSpring(artisynth.core.mechmodels.AxialSpring)

Example 12 with Particle

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

the class PointModel method add3dMuscles.

public void add3dMuscles() {
    int[] x = new int[] { -1, 0, 1 };
    int[] y = new int[] { -1, 0, 1 };
    int[] z = new int[] { -1, 0, 1 };
    double eps = 1e-4;
    for (int i = 0; i < x.length; i++) {
        for (int j = 0; j < y.length; j++) {
            for (int k = 0; k < z.length; k++) {
                Point3d pnt = new Point3d(x[i], y[j], z[k]);
                if (pnt.x == 0 || pnt.y == 0 || pnt.z == 0)
                    continue;
                // if (pnt.norm() < 1e-4 || pnt.norm() > Math.sqrt(2))
                // continue;
                // if (pnt.norm() < 1e-4 || pnt.norm() > 1.0)
                // continue;
                pnt.normalize();
                pnt.scale(len);
                Particle endPt = new Particle(mass, pnt);
                endPt.setDynamic(false);
                model.addParticle(endPt);
                Muscle m = addMuscle(endPt);
                m.setName(String.format("x%dy%dz%d", x[i], y[j], z[k]));
                RenderProps.setLineColor(m, Color.RED);
            }
        }
    }
}
Also used : Particle(artisynth.core.mechmodels.Particle) Point3d(maspack.matrix.Point3d) LinearAxialMuscle(artisynth.core.materials.LinearAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) Point(artisynth.core.mechmodels.Point) SphericalJoint(artisynth.core.mechmodels.SphericalJoint)

Example 13 with Particle

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

the class TorusWrapTest method build.

public void build(String[] args) {
    MechModel mechMod = new MechModel("mechMod");
    mechMod.setGravity(0, 0, -9.8);
    mechMod.setFrameDamping(10.0);
    mechMod.setRotaryDamping(0.1);
    RigidBody block = new RigidBody("block");
    PolygonalMesh mesh = MeshFactory.createBox(size, size, size);
    block.setMesh(mesh, null);
    block.setInertiaFromDensity(1);
    // mechMod.addRigidBody (block);
    Particle p0 = new Particle(0.1, size * 3, 0, size / 2);
    p0.setDynamic(false);
    mechMod.addParticle(p0);
    Particle p1 = new Particle(0.1, -size * 3, 0, size / 2);
    p1.setDynamic(false);
    mechMod.addParticle(p1);
    Particle p2 = new Particle(0.1, -size * 3, size, size / 2);
    p2.setDynamic(false);
    // mechMod.addParticle (p2);
    Particle p3 = new Particle(0.1, size * 3, size, size / 2);
    p3.setDynamic(false);
    // mechMod.addParticle (p3);
    RigidTorus torus1 = new RigidTorus("torus1", size, size / 3, myDensity, 50, 30);
    RigidTorus torus2 = new RigidTorus("torus2", size, size / 3, myDensity, 50, 30);
    RigidTorus torus3 = new RigidTorus("torus3", size, size / 3, myDensity, 50, 30);
    torus1.setPose(new RigidTransform3d(-2 * size, 0, 0, 0, Math.PI / 2, 0));
    torus2.setPose(new RigidTransform3d(2 * size, 0, 0, 0, Math.PI / 2, 0));
    torus3.setPose(new RigidTransform3d(0, 0, 0, 0, Math.PI / 2, 0));
    mechMod.addRigidBody(torus1);
    mechMod.addRigidBody(torus2);
    mechMod.addRigidBody(torus3);
    mechMod.setDefaultCollisionBehavior(true, 0);
    MultiPointSpring spring = new MultiPointSpring("spring", 100, 0.1, 0);
    spring.addPoint(p0);
    spring.setSegmentWrappable(50);
    spring.addWrappable(torus1);
    spring.addWrappable(torus2);
    spring.addWrappable(torus3);
    spring.addPoint(p1);
    // spring.addPoint (p2);
    // spring.setSegmentWrappable (50);
    // spring.addPoint (p3);
    // spring.setWrapDamping (1.0);
    // spring.setWrapStiffness (10);
    // spring.setWrapH (0.01);
    mechMod.addMultiPointSpring(spring);
    spring.setDrawKnots(false);
    spring.setDrawABPoints(true);
    spring.setWrapDamping(100);
    spring.setMaxWrapIterations(10);
    addModel(mechMod);
    RenderProps.setPointStyle(mechMod, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(mechMod, size / 10);
    RenderProps.setLineStyle(mechMod, Renderer.LineStyle.CYLINDER);
    RenderProps.setLineRadius(mechMod, size / 30);
    RenderProps.setLineColor(mechMod, Color.red);
    createControlPanel(mechMod);
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) RigidBody(artisynth.core.mechmodels.RigidBody) PolygonalMesh(maspack.geometry.PolygonalMesh) RigidTorus(artisynth.core.mechmodels.RigidTorus) MultiPointSpring(artisynth.core.mechmodels.MultiPointSpring)

Example 14 with Particle

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

the class TwoStrandWrapBase method build.

public void build(String[] args) {
    myMech = new MechModel("mechMod");
    myMech.setGravity(0, 0, -9.8);
    myMech.setFrameDamping(1.0);
    myMech.setRotaryDamping(0.1);
    myP0 = new Particle(0.1, size * 3, -myGap / 2, size / 2);
    myP0.setDynamic(false);
    myMech.addParticle(myP0);
    myP1 = new Particle(0.1, -size * 3, -myGap / 2, size / 2);
    myP1.setDynamic(false);
    myMech.addParticle(myP1);
    myP2 = new Particle(0.1, -size * 3, myGap / 2, size / 2);
    myP2.setDynamic(false);
    myMech.addParticle(myP2);
    myP3 = new Particle(0.1, size * 3, myGap / 2, size / 2);
    myP3.setDynamic(false);
    myMech.addParticle(myP3);
    mySpring = new MultiPointSpring("spring", 1, 0.1, 0);
    mySpring.addPoint(myP0);
    mySpring.setSegmentWrappable(50);
    mySpring.addPoint(myP1);
    mySpring.addPoint(myP2);
    mySpring.setSegmentWrappable(50);
    mySpring.addPoint(myP3);
    // mySpring.setWrapDamping (1.0);
    // mySpring.setWrapStiffness (10);
    // mySpring.setWrapH (0.01);
    myMech.addMultiPointSpring(mySpring);
    mySpring.setDrawKnots(false);
    mySpring.setDrawABPoints(true);
    mySpring.setWrapDamping(100);
    mySpring.setMaxWrapIterations(10);
    addModel(myMech);
    RenderProps.setPointStyle(myMech, Renderer.PointStyle.SPHERE);
    RenderProps.setPointRadius(myMech, size / 10);
    RenderProps.setLineStyle(myMech, Renderer.LineStyle.CYLINDER);
    RenderProps.setLineRadius(myMech, size / 30);
    RenderProps.setLineColor(myMech, Color.red);
    createControlPanel(myMech);
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel) MultiPointSpring(artisynth.core.mechmodels.MultiPointSpring)

Example 15 with Particle

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

the class CylinderWrapping method build.

public void build(String[] args) {
    MechModel mechMod = new MechModel("mechMod");
    addModel(mechMod);
    mechMod.setGravity(0, 0, -9.8);
    mechMod.setFrameDamping(100.0);
    mechMod.setRotaryDamping(10.0);
    double density = 150;
    double size = 1.0;
    Particle p1 = new Particle(0.1, -size, 0, 4 * size);
    p1.setDynamic(false);
    mechMod.addParticle(p1);
    Particle p2 = new Particle(0.1, -size, 0, 0);
    p2.setDynamic(false);
    mechMod.addParticle(p2);
    // create cylindrical wrapping object
    RigidCylinder cylinder = new RigidCylinder("cylinder", size / 2, 3.5 * size, density, 50);
    cylinder.setPose(new RigidTransform3d(0, 0, 1.5 * size, 0, 0, Math.PI / 2));
    cylinder.setDynamic(false);
    mechMod.addRigidBody(cylinder);
    // create ellipsoidal wrapping object
    double rad = 0.6 * size;
    RigidEllipsoid ball = new RigidEllipsoid("ball", rad, 2 * rad, rad, density, 50);
    ball.transformGeometry(new RigidTransform3d(size * 3, 0, 0));
    mechMod.addRigidBody(ball);
    // attach a marker to the ball
    FrameMarker p0 = new FrameMarker();
    double halfRoot2 = Math.sqrt(2) / 2;
    mechMod.addFrameMarker(p0, ball, new Point3d(-rad * halfRoot2, 0, rad * halfRoot2));
    // enable collisions between the ball and cylinder
    mechMod.setCollisionBehavior(cylinder, ball, true);
    // create the spring, making the segments between p0-p1 and p1-p2 each
    // wrappable with 50 knot points each
    MultiPointSpring spring = new MultiPointSpring("spring", 300, 1.0, 0);
    spring.addPoint(p0);
    spring.setSegmentWrappable(50, new Point3d[] { new Point3d(3, 0, 3) });
    spring.addWrappable(cylinder);
    spring.addWrappable(ball);
    spring.addPoint(p1);
    spring.setSegmentWrappable(50);
    spring.addPoint(p2);
    // optional: shrink wrapping segments around obstacles
    spring.updateWrapSegments();
    mechMod.addMultiPointSpring(spring);
    // set various rendering properties
    RenderProps.setSphericalPoints(p0, size / 10, Color.WHITE);
    RenderProps.setSphericalPoints(p1, size / 5, Color.BLUE);
    RenderProps.setSphericalPoints(p2, size / 10, Color.WHITE);
    RenderProps.setSphericalPoints(spring, size / 10, Color.GRAY);
    RenderProps.setCylindricalLines(spring, size / 30, Color.RED);
    createControlPanel(spring);
}
Also used : Particle(artisynth.core.mechmodels.Particle) MechModel(artisynth.core.mechmodels.MechModel) RigidTransform3d(maspack.matrix.RigidTransform3d) FrameMarker(artisynth.core.mechmodels.FrameMarker) RigidEllipsoid(artisynth.core.mechmodels.RigidEllipsoid) Point3d(maspack.matrix.Point3d) RigidCylinder(artisynth.core.mechmodels.RigidCylinder) MultiPointSpring(artisynth.core.mechmodels.MultiPointSpring)

Aggregations

Particle (artisynth.core.mechmodels.Particle)21 Point3d (maspack.matrix.Point3d)12 AxialSpring (artisynth.core.mechmodels.AxialSpring)10 MechModel (artisynth.core.mechmodels.MechModel)8 RigidBody (artisynth.core.mechmodels.RigidBody)5 FrameMarker (artisynth.core.mechmodels.FrameMarker)4 Muscle (artisynth.core.mechmodels.Muscle)4 Point (artisynth.core.mechmodels.Point)4 SphericalJoint (artisynth.core.mechmodels.SphericalJoint)4 RigidTransform3d (maspack.matrix.RigidTransform3d)4 MultiPointSpring (artisynth.core.mechmodels.MultiPointSpring)3 RenderProps (maspack.render.RenderProps)3 FemMarker (artisynth.core.femmodels.FemMarker)2 LinearAxialMuscle (artisynth.core.materials.LinearAxialMuscle)2 SimpleAxialMuscle (artisynth.core.materials.SimpleAxialMuscle)2 PolygonalMesh (maspack.geometry.PolygonalMesh)2 FemElement (artisynth.core.femmodels.FemElement)1 FemNode (artisynth.core.femmodels.FemNode)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 ConnectorForceRenderer (artisynth.core.inverse.ConnectorForceRenderer)1