Search in sources :

Example 11 with MuscleBundle

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);
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Point3d(maspack.matrix.Point3d) Muscle(artisynth.core.mechmodels.Muscle) ConstantAxialMuscle(artisynth.core.materials.ConstantAxialMuscle)

Example 12 with MuscleBundle

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);
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle)

Example 13 with MuscleBundle

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);
        }
    }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Point3d(maspack.matrix.Point3d) Muscle(artisynth.core.mechmodels.Muscle) ConstantAxialMuscle(artisynth.core.materials.ConstantAxialMuscle)

Example 14 with MuscleBundle

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));
// }
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) Color(java.awt.Color) ArrayList(java.util.ArrayList) Muscle(artisynth.core.mechmodels.Muscle)

Example 15 with MuscleBundle

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();
}
Also used : MuscleBundle(artisynth.core.femmodels.MuscleBundle) MuscleExciter(artisynth.core.mechmodels.MuscleExciter)

Aggregations

MuscleBundle (artisynth.core.femmodels.MuscleBundle)25 Muscle (artisynth.core.mechmodels.Muscle)6 FemElement3d (artisynth.core.femmodels.FemElement3d)4 ConstantAxialMuscle (artisynth.core.materials.ConstantAxialMuscle)4 Point3d (maspack.matrix.Point3d)4 FemMuscleModel (artisynth.core.femmodels.FemMuscleModel)3 Point (artisynth.core.mechmodels.Point)3 Color (java.awt.Color)3 DoubleFieldSlider (maspack.widgets.DoubleFieldSlider)3 TrackingController (artisynth.core.inverse.TrackingController)2 SimpleForceMuscle (artisynth.core.materials.SimpleForceMuscle)2 MuscleExciter (artisynth.core.mechmodels.MuscleExciter)2 Point (java.awt.Point)2 LinkedList (java.util.LinkedList)2 RenderProps (maspack.render.RenderProps)2 FemMarker (artisynth.core.femmodels.FemMarker)1 FemMeshComp (artisynth.core.femmodels.FemMeshComp)1 FemNode (artisynth.core.femmodels.FemNode)1 FemNode3d (artisynth.core.femmodels.FemNode3d)1 MuscleElementDesc (artisynth.core.femmodels.MuscleElementDesc)1