Search in sources :

Example 21 with NumericListKnot

use of maspack.interpolation.NumericListKnot in project artisynth_core by artisynth.

the class NumericInputProbe method setData.

public void setData(double sec) {
    double t = getVirtualTime(sec);
    myNumericList.interpolate(myTmpVec, t);
    myTmpVec.setZero();
    double[] buf = myTmpVec.getBuffer();
    int k = 0;
    // load all channels
    for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
        for (int i = 0; i < myDrivers.size(); i++) {
            NumericProbeDriver driver = myDrivers.get(i);
            if (driver.usesVariable(entry.getKey())) {
                // set variable at buf[k];
                Object val = myPropList.get(i).get();
                double[] array = myConverters[i].objectToArray(myPropList.get(i).get());
                for (int j = 0; j < array.length; j++) {
                    buf[k + j] = array[j];
                }
                break;
            }
        }
        k += entry.getValue().getDimension();
    }
    NumericListKnot knot = new NumericListKnot(myTmpVec.size());
    knot.v.set(myTmpVec);
    knot.t = t;
    myNumericList.add(knot);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 22 with NumericListKnot

use of maspack.interpolation.NumericListKnot in project artisynth_core by artisynth.

the class NumericMonitorProbe method writeData.

public void writeData(PrintWriter pw, String fmtStr, boolean showTime) {
    NumberFormat timeFmt = null;
    if (showTime) {
        if (getUpdateInterval() < 1e-5) {
            timeFmt = new NumberFormat("%12.9f");
        } else {
            timeFmt = new NumberFormat("%9.6f");
        }
    }
    NumberFormat fmt = new NumberFormat(fmtStr);
    Iterator<NumericListKnot> it = myNumericList.iterator();
    while (it.hasNext()) {
        NumericListKnot knot = it.next();
        if (showTime) {
            pw.print(timeFmt.format(knot.t) + " ");
        }
        pw.println(knot.v.toString(fmt));
    }
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 23 with NumericListKnot

use of maspack.interpolation.NumericListKnot in project artisynth_core by artisynth.

the class NumericMonitorProbe method apply.

public void apply(double t) {
    // XXX don't we want to apply scaling here too?
    double trel = (t - getStartTime()) / myScale;
    NumericListKnot knot = new NumericListKnot(myVsize);
    generateData(knot.v, t, trel);
    knot.t = trel;
    myNumericList.add(knot);
    myNumericList.clearAfter(knot);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 24 with NumericListKnot

use of maspack.interpolation.NumericListKnot in project artisynth_core by artisynth.

the class PointTracingProbe method updateBounds.

public void updateBounds(Vector3d pmin, Vector3d pmax) {
    if (myNumericList == null) {
        return;
    }
    Point3d pnt = new Point3d();
    for (NumericListKnot knot : myNumericList) {
        VectorNd v = knot.v;
        pnt.x = v.get(0);
        pnt.y = v.get(1);
        pnt.z = v.get(2);
        pnt.updateBounds(pmin, pmax);
    }
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot) Point3d(maspack.matrix.Point3d) VectorNd(maspack.matrix.VectorNd)

Aggregations

NumericListKnot (maspack.interpolation.NumericListKnot)24 VectorNd (maspack.matrix.VectorNd)3 PlotTraceInfo (artisynth.core.probes.PlotTraceInfo)2 Point (java.awt.Point)2 NumericList (maspack.interpolation.NumericList)2 BasicStroke (java.awt.BasicStroke)1 Graphics2D (java.awt.Graphics2D)1 ImproperStateException (maspack.matrix.ImproperStateException)1 Matrix3d (maspack.matrix.Matrix3d)1 Point3d (maspack.matrix.Point3d)1 Quaternion (maspack.matrix.Quaternion)1 RotationMatrix3d (maspack.matrix.RotationMatrix3d)1 Vector3d (maspack.matrix.Vector3d)1