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);
}
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);
}
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);
}
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));
}
}
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();
}
Aggregations