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;
}
}
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);
}
}
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;
}
}
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);
}
}
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);
}
Aggregations