use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.
the class HydrostatModel method createBundle.
public void createBundle(String name, Point3d emin, Point3d emax, String prefix) {
Point3d pmin = new Point3d();
Point3d pmax = new Point3d();
MuscleBundle newbundle = new MuscleBundle(name);
addMuscleBundle(newbundle);
RenderProps.setLineWidth(newbundle, 4);
// great than check -- use minus minimum
emin.negate();
for (Muscle f : muscleFibres) {
pmin.set(Double.MAX_VALUE, Double.MAX_VALUE, Double.MAX_VALUE);
pmax.set(-Double.MAX_VALUE, -Double.MAX_VALUE, -Double.MAX_VALUE);
f.updateBounds(pmin, pmax);
// great than check -- use minus minimum
pmin.negate();
if (f.getName().startsWith(prefix) && emax.greaterEquals(pmax) && emin.greaterEquals(pmin))
newbundle.addFibre(f);
}
}
use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.
the class HydrostatModel method addMuscles.
public void addMuscles(Shape s) {
switch(s) {
case Tentacle:
addTentacleMuscles();
addTentacleExciters();
break;
case Beam:
addBeamMuscles();
break;
case Tube:
addTubeMuscles();
break;
default:
System.err.println("HydrostatDemo unknown shape " + s.toString());
}
for (MuscleBundle b : myMuscleList) {
b.setFibresActive(true);
}
}
use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.
the class HydrostatModel method createTubeLongMuscles.
public void createTubeLongMuscles() {
MuscleBundle bundle = new MuscleBundle("long");
addMuscleBundle(bundle);
RenderProps.setLineWidth(bundle, 4);
RenderProps.setLineColor(bundle, Color.RED);
Point3d p0 = new Point3d();
Point3d p1 = new Point3d();
double dl = l / (nl - 1);
double dt = 2 * Math.PI / nt;
double dr = (r - rin) / (nr - 1);
for (double i = 0; i < nt; i++) for (double j = (periphLongP ? nr - 1 : 0); j < nr; j++) {
for (double k = 0; k < nl - 1; k++) {
p0.set(-l / 2 + k * dl, -(rin + dr * j) * Math.cos(dt * i), (rin + dr * j) * Math.sin(dt * i));
p1.set(-l / 2 + (k + 1) * dl, -(rin + dr * j) * Math.cos(dt * i), (rin + dr * j) * Math.sin(dt * i));
Muscle f = new Muscle(findPoint(p0), findPoint(p1));
f.setConstantMuscleMaterial(muscleForce, 1);
bundle.addFibre(f);
}
}
}
use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.
the class HydrostatInvDemo method setupRenderProps.
public void setupRenderProps() {
RenderProps.setFaceStyle(hydro, FaceStyle.FRONT);
RenderProps.setFaceColor(hydro, new Color(0.8f, 0.8f, 1f));
RenderProps.setVisible(hydro.getElements(), false);
RenderProps.setPointSize(hydro.getNodes(), 0);
ArrayList<Muscle> visibleMuscles = new ArrayList<Muscle>();
for (MuscleBundle b : hydro.getMuscleBundles()) {
String name = b.getName();
RenderProps.setLineRadiusMode(b, PropertyMode.Inherited);
// if (name.startsWith("horz") || name.startsWith("vert")) {
// for (Muscle m : b)
// visibleMuscles.add(m);
// }
// else
// RenderProps.setVisible(b, false);
}
RenderProps.setLineRadius(hydro.getMuscleBundles(), s * 0.75);
// float h = 1f / (float)visibleMuscles.size();
// for (int i = 0; i < visibleMuscles.size(); i++) {
// System.out.println("h = "+i*h);
// RenderProps.setLineColor(visibleMuscles.get(i), Color.getHSBColor (i*h, 1f, 1f));
// }
}
use of artisynth.core.femmodels.MuscleBundle in project artisynth_core by artisynth.
the class SpongeDemo method build.
// boolean kinematic = false;
public void build(String[] args) throws IOException {
sponge = new SpongeModel("sponge");
addModel(sponge);
MuscleExciter exciter = new MuscleExciter("gang");
exciter.addTarget(sponge.getMuscleBundles().get(0), 1.0);
exciter.addTarget(sponge.getMuscleBundles().get(1), 1.0);
exciter.addTarget(sponge.getMuscleBundles().get(2), 1.0);
sponge.addMuscleExciter(exciter);
MuscleExciter all = new MuscleExciter("all");
for (MuscleBundle b : sponge.getMuscleBundles()) {
all.addTarget(b, 1.0);
}
sponge.addMuscleExciter(all);
sponge.setSurfaceRendering(SurfaceRender.Shaded);
RenderProps.setAlpha(sponge, 0.5);
// loadProbes();
// build solve matrix to set solve indices
// SparseBlockMatrix M = sponge.getSolveMatrix();
// System.out.printf("M size = (%d, %d), nonzero = %d\n", M.rowSize(),
// M.colSize(), M.numNonZeroVals()); // + J.toString("%8.2e"));
// SparseBlockMatrix J = sponge.updateActJacobian(1.0);
// System.out.printf("J size = (%d, %d), nonzero = %d\n", J.rowSize(),
// J.colSize(), J.numNonZeroVals()); // + J.toString("%8.2e"));
// System.out.println("J = \n" + J.toString("%8.2e"));
// testActJacobian();
// printSparseJacobian();
addControlPanel();
}
Aggregations