Search in sources :

Example 66 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class MLSShapeFunction method evalDerivative.

public double evalDerivative(MFreeNode3d node, MFreeNode3d[] nodes, Point3d in, int[] derivatives, MatrixNd MInv) {
    VectorNd pi = new VectorNd(nBasis);
    MFreeWeightFunction fun = node.getWeightFunction();
    Point3d xi = node.getRestPosition();
    double w = fun.eval(in);
    computeP(pi, xi.x, xi.y, xi.z);
    return evalDerivative(node, nodes, in, pi, w, derivatives, MInv);
}
Also used : Point3d(maspack.matrix.Point3d) VectorNd(maspack.matrix.VectorNd)

Example 67 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class MLSShapeFunction method computeDPCorrelation.

protected void computeDPCorrelation(MatrixNd out, double x, double y, double z, int dx, int dy, int dz) {
    VectorNd _p = new VectorNd(nBasis);
    computeDP(_p, x, y, z, dx, dy, dz);
    computeCorrelation(out, _p);
}
Also used : VectorNd(maspack.matrix.VectorNd)

Example 68 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class ForceTargetDemo method addTrackingController.

public void addTrackingController(FrameMarker mkr) throws IOException {
    TrackingController myTrackingController = new TrackingController(mech, "tcon");
    for (AxialSpring s : mech.axialSprings()) {
        if (s instanceof Muscle) {
            myTrackingController.addExciter((Muscle) s);
        }
    }
    // myTrackingController.addTerm(new StiffnessTerm(model, center));
    // StiffnessTerm kTerm = TrackingController.addStiffnessTarget(center, new int[]{0,2});
    // kTerm.setStiffnessTargetType(StiffnessTargetType.DIAG);
    // ComplianceTerm2d cterm = new ComplianceTerm2d(TrackingController, center, new int[]{0,2});
    // cterm.setComplianceTargetType(StiffnessTargetType.DIAG);
    // TrackingController.addTerm(cterm);
    myTrackingController.addL2RegularizationTerm();
    // myTrackingController.addTerm(new DampingTerm(TrackingController));
    // myTrackingController.addTerm(new StaticMotionTargetTerm(TrackingController));
    myTrackingController.addMotionTarget(mkr);
    setPointRenderProps((TargetPoint) myTrackingController.getMotionTargets().get(0));
    ForceTargetTerm mft = new ForceTargetTerm(myTrackingController);
    // mft.addMotionTarget(mkr);
    // setPointRenderProps((TargetPoint) mft.getMotionTargets ().get (0));
    double[] lam = { -3.5 };
    VectorNd tarlam = new VectorNd(lam);
    if (cons == true) {
        ForceTarget ft = mft.addForceTarget(con);
        ft.setTargetLambda(tarlam);
    }
    if (two_cons == true) {
        ForceTarget ft = mft.addForceTarget(con2);
        ft.setTargetLambda(tarlam);
    }
    if (force == true) {
        myTrackingController.addForceTargetTerm(mft);
    }
    // myTrackingController.getSolver().setBounds(0.01, 0.99);
    // setWorkingDir();
    // loadForceInputProbe(mft);
    myTrackingController.setProbeDuration(10.0);
    myTrackingController.createProbesAndPanel(this);
    addController(myTrackingController);
    reloadTargetProbeData();
}
Also used : VectorNd(maspack.matrix.VectorNd) SimpleAxialMuscle(artisynth.core.materials.SimpleAxialMuscle) Muscle(artisynth.core.mechmodels.Muscle) ForceTargetTerm(artisynth.core.inverse.ForceTargetTerm) ForceTarget(artisynth.core.inverse.ForceTarget) AxialSpring(artisynth.core.mechmodels.AxialSpring) TrackingController(artisynth.core.inverse.TrackingController)

Example 69 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class RectangleField method textToValue.

public Object textToValue(String text, BooleanHolder corrected, StringHolder errMsg) {
    corrected.value = false;
    Object value = super.textToValue(text, corrected, errMsg);
    if (value == Property.IllegalValue) {
        return Property.IllegalValue;
    }
    if (value instanceof VectorNd) {
        VectorNd tmp = (VectorNd) value;
        value = new Rectangle2d(tmp.get(0), tmp.get(1), tmp.get(2), tmp.get(3));
    }
    return validValue(value, errMsg);
}
Also used : VectorNd(maspack.matrix.VectorNd) Rectangle2d(maspack.geometry.Rectangle2d)

Example 70 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class VariableVectorField method textToValue.

public Object textToValue(String text, BooleanHolder corrected, StringHolder errMsg) {
    corrected.value = false;
    if (isBlank(text)) {
        return setVoidIfPossible(errMsg);
    }
    ReaderTokenizer rtok = new ReaderTokenizer(new StringReader(text));
    VectorNd tmp = new VectorNd(myVectorSize);
    int idx = 0;
    try {
        while (rtok.nextToken() != ReaderTokenizer.TT_EOF) {
            if (idx == tmp.size()) {
                tmp.adjustSize(5);
            }
            if (rtok.ttype == ReaderTokenizer.TT_NUMBER) {
                tmp.set(idx++, rtok.nval);
            } else {
                return illegalValue("Malformed number for element " + idx, errMsg);
            }
        }
    } catch (Exception e) {
        return illegalValue("Error parsing text", errMsg);
    }
    tmp.setSize(idx);
    return validValue(tmp, errMsg);
}
Also used : ReaderTokenizer(maspack.util.ReaderTokenizer) StringReader(java.io.StringReader) VectorNd(maspack.matrix.VectorNd)

Aggregations

VectorNd (maspack.matrix.VectorNd)136 Point (artisynth.core.mechmodels.Point)29 Point3d (maspack.matrix.Point3d)16 Vector3d (maspack.matrix.Vector3d)15 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)11 ArrayList (java.util.ArrayList)11 ContactPoint (artisynth.core.mechmodels.ContactPoint)9 MatrixNd (maspack.matrix.MatrixNd)9 Vertex3d (maspack.geometry.Vertex3d)8 SparseMatrixNd (maspack.matrix.SparseMatrixNd)8 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)7 PointAttachment (artisynth.core.mechmodels.PointAttachment)7 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)6 FemNode (artisynth.core.femmodels.FemNode)5 PolygonalMesh (maspack.geometry.PolygonalMesh)5 ReaderTokenizer (maspack.util.ReaderTokenizer)5 FemNode3d (artisynth.core.femmodels.FemNode3d)4 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)4 StringReader (java.io.StringReader)4 HashMap (java.util.HashMap)4