Search in sources :

Example 11 with NumericListKnot

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

the class NumericInputProbe method addData.

public void addData(double t, double[] v) {
    if (v.length != myVsize) {
        throw new IllegalArgumentException("input vector has size " + v.length + " vs. " + myVsize);
    }
    NumericListKnot knot = new NumericListKnot(myVsize);
    knot.t = t;
    knot.v.set(v);
    myNumericList.add(knot);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 12 with NumericListKnot

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

the class NumericInputProbe method writeItems.

public void writeItems(PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor) throws IOException {
    super.writeItems(pw, fmt, ancestor);
    pw.println("vsize=" + getVsize());
    if (myPropList != null && myPropList.size() > 0) {
        pw.println("props=[");
        IndentingPrintWriter.addIndentation(pw, 2);
        for (int i = 0; i < myPropList.size(); i++) {
            pw.println(ComponentUtils.getWritePropertyPathName(myPropList.get(i), ancestor));
        }
        IndentingPrintWriter.addIndentation(pw, -2);
        pw.println("]");
        pw.println("drivers=[");
        IndentingPrintWriter.addIndentation(pw, 2);
        for (NumericProbeDriver driver : myDrivers) {
            pw.println(driver);
        }
        IndentingPrintWriter.addIndentation(pw, -2);
        pw.println("]");
    } else {
        pw.println("props=[ ]");
    }
    if (myVariables != null && myVariables.size() > 0) {
        pw.println("inputs=[");
        IndentingPrintWriter.addIndentation(pw, 2);
        for (Map.Entry<String, NumericProbeVariable> entry : myVariables.entrySet()) {
            pw.println(entry.getKey() + " " + entry.getValue().getDimension());
        }
        IndentingPrintWriter.addIndentation(pw, -2);
        pw.println("]");
    } else {
        pw.println("inputs=[ ]");
    }
    pw.println("data=[");
    IndentingPrintWriter.addIndentation(pw, 2);
    for (NumericListKnot knot : myNumericList) {
        pw.print(fmt.format(knot.t) + " ");
        pw.println(knot.v.toString(fmt));
    }
    IndentingPrintWriter.addIndentation(pw, -2);
    pw.println("]");
    maybeWritePlotTraceInfo(pw);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 13 with NumericListKnot

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

the class NumericControlProbe method scanItem.

public boolean scanItem(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    rtok.nextToken();
    if (scanAttributeName(rtok, "plotTraceInfo")) {
        tmpTraceInfos = scanPlotTraceInfo(rtok);
        return true;
    } else if (scanAttributeName(rtok, "data")) {
        createNumericList(getVsize());
        rtok.scanToken('[');
        while (rtok.nextToken() != ']') {
            rtok.pushBack();
            NumericListKnot knot = new NumericListKnot(myVsize);
            knot.t = rtok.scanNumber();
            for (int i = 0; i < myVsize; i++) {
                knot.v.set(i, rtok.scanNumber());
            }
            myNumericList.add(knot);
        }
        return true;
    } else if (scanAttributeName(rtok, "vsize")) {
        myVsize = rtok.scanInteger();
        return true;
    }
    rtok.pushBack();
    return super.scanItem(rtok, tokens);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 14 with NumericListKnot

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

the class NumericControlProbe method addData.

/**
 * Adds one or more data samples to internal data list.<br>
 * <br>
 * Samples can be evenly distributed with given time step or time of each
 * sample can be explicitly set. In this case, timeStep must have value of
 * {@link #EXPLICIT_TIME} and before every data sample must be its temporal
 * information.<br>
 *
 * Internal data sample size of this input probe can be determined by
 * {@link #getVsize()} method.
 *
 * @param data
 * data array, which can contain multiple data samples
 * @param timeStep
 * time step in seconds or {@link #EXPLICIT_TIME} if data contains explicitly
 * set timestamps
 */
public void addData(double[] data, double timeStep) {
    int recSize = (timeStep == EXPLICIT_TIME ? myVsize + 1 : myVsize);
    int k = 0;
    double time = 0;
    while (k < data.length - recSize + 1) {
        NumericListKnot knot = new NumericListKnot(myVsize);
        if (timeStep == EXPLICIT_TIME) {
            knot.t = data[k++];
            time = knot.t;
        } else {
            knot.t = time;
            time += timeStep;
        }
        for (int i = 0; i < myVsize; i++) {
            knot.v.set(i, data[k++]);
        }
        myNumericList.add(knot);
    }
// extendStopTimeIfNecessary();
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 15 with NumericListKnot

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

the class NumericControlProbe method addData.

public void addData(ReaderTokenizer rtok, double timeStep) throws IOException {
    double time = 0;
    // If zero vector size, don't bother adding data
    if (myVsize == 0) {
        return;
    }
    while (rtok.nextToken() != ReaderTokenizer.TT_EOF) {
        NumericListKnot knot = new NumericListKnot(myVsize);
        if (timeStep == EXPLICIT_TIME) {
            if (rtok.ttype != ReaderTokenizer.TT_NUMBER) {
                throw new IOException("Expected time value, line " + rtok.lineno());
            }
            knot.t = rtok.nval;
            time = knot.t;
        } else {
            knot.t = time;
            time += timeStep;
            rtok.pushBack();
        }
        if (rtok.scanNumbers(knot.v.getBuffer(), myVsize) != myVsize) {
            if (rtok.ttype == ReaderTokenizer.TT_EOF) {
                return;
            } else {
                throw new IOException("Unexpected token " + rtok.tokenName() + ", line " + rtok.lineno());
            }
        }
        myNumericList.add(knot);
    }
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

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