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