use of artisynth.core.mechmodels.MultiPointSpring 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);
}
use of artisynth.core.mechmodels.MultiPointSpring 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);
}
use of artisynth.core.mechmodels.MultiPointSpring 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);
}
Aggregations