Search in sources :

Example 16 with NumericListKnot

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

the class NumericControlProbe method writeItems.

public void writeItems(PrintWriter pw, NumberFormat fmt, CompositeComponent ancestor) throws IOException {
    super.writeItems(pw, fmt, ancestor);
    pw.println("vsize=" + getVsize());
    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 17 with NumericListKnot

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

the class NumericInputProbe method loadEmpty.

public void loadEmpty() {
    NumericListKnot knotStart = new NumericListKnot(myVsize);
    NumericListKnot knotEnd = new NumericListKnot(myVsize);
    knotStart.t = getStartTime();
    knotEnd.t = getStopTime();
    myNumericList.add(knotStart);
    myNumericList.add(knotEnd);
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 18 with NumericListKnot

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

the class NumericInputProbe method scanItem.

public boolean scanItem(ReaderTokenizer rtok, Deque<ScanToken> tokens) throws IOException {
    rtok.nextToken();
    if (ScanWriteUtils.scanAndStorePropertyPaths(rtok, "props", tokens) >= 0) {
        return true;
    } else if (scanAttributeName(rtok, "drivers")) {
        tmpDriverExpressions = Scan.scanQuotedStrings(rtok, '"');
        return true;
    } else if (scanAttributeName(rtok, "inputs")) {
        rtok.scanToken('[');
        ArrayList<String> stringList = new ArrayList<String>();
        ArrayList<Integer> intList = new ArrayList<Integer>();
        while (rtok.nextToken() != ']') {
            if (!rtok.tokenIsWord()) {
                throw new IOException("expected variable name; got " + rtok);
            }
            stringList.add(rtok.sval);
            intList.add(rtok.scanInteger());
        }
        tmpVariableNames = stringList.toArray(new String[0]);
        tmpVariableDimensions = new int[intList.size()];
        for (int i = 0; i < tmpVariableDimensions.length; i++) {
            tmpVariableDimensions[i] = intList.get(i);
        }
        return true;
    } else 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 19 with NumericListKnot

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

the class NumericInputProbe method write.

/**
 * Writes the start and stop times, scale value, and data for this probe to a
 * PrintWriter, using the format described for {@link #read(File,boolean)
 * read(File)}. The format used for producing floating point numbers can be
 * controlled using a printf-style format string, details of which are
 * described in {@link maspack.util.NumberFormat NumberFormat}.
 *
 * @param pw
 * writer which accepts the output
 * @param fmtStr
 * printf-style format string (if set to null then "%g" will be assumed,
 * which will produce full precision output).
 * @throws IOException
 * if an I/O error occurs.
 */
public void write(PrintWriter pw, String fmtStr) throws IOException {
    pw.println(getStartTime() + " " + getStopTime() + " " + myScale);
    pw.print(myInterpolation.getOrder() + " " + myNumericList.getVectorSize());
    pw.println(" explicit");
    if (fmtStr == null) {
        fmtStr = "%g";
    }
    NumberFormat fmt = new NumberFormat(fmtStr);
    Iterator<NumericListKnot> it = myNumericList.iterator();
    while (it.hasNext()) {
        NumericListKnot knot = it.next();
        pw.println(fmt.format(knot.t) + "  " + knot.v.toString(fmt));
    }
}
Also used : NumericListKnot(maspack.interpolation.NumericListKnot)

Example 20 with NumericListKnot

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

the class NumericInputProbe method addData.

/**
 * Adds data to internal data list.
 *
 * @param t
 * time in seconds
 * @param v
 * vector of values
 *
 * @throws IllegalArgumentException
 * if size of vector is not equal to {@link #getVsize()}
 */
public void addData(double t, VectorNd v) {
    if (v.size() != myVsize) {
        throw new IllegalArgumentException("input vector has size " + v.size() + " vs. " + myVsize);
    }
    NumericListKnot knot = new NumericListKnot(myVsize);
    knot.t = t;
    knot.v.set(v);
    myNumericList.add(knot);
// extendStopTimeIfNecessary();
}
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