Search in sources :

Example 56 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class NumericInputProbe method set.

public void set(Property[] props, String[] driverExpressions, String[] variableNames, int[] variableDimensions, PlotTraceInfo[] traceInfos) {
    if (props.length != driverExpressions.length) {
        throw new IllegalArgumentException("number of drivers must equal number of properties");
    }
    if (variableNames.length != variableDimensions.length) {
        throw new IllegalArgumentException("number of channels must equal number of variable names");
    }
    NumericConverter[] newConverters = createConverters(props);
    LinkedHashMap<String, NumericProbeVariable> newVariables = new LinkedHashMap<String, NumericProbeVariable>();
    int newVsize = 0;
    for (int i = 0; i < variableNames.length; i++) {
        String name = variableNames[i];
        if (name == null || newVariables.get(name) != null) {
            throw new IllegalArgumentException("null or repeated variable name '" + name + "'");
        }
        if (!isValidVariableName(name)) {
            throw new IllegalArgumentException("variable name '" + name + "' is not a valid variable name");
        }
        if (variableDimensions[i] <= 0) {
            throw new IllegalArgumentException("channel sizes must be greater than 0");
        }
        newVariables.put(name, new NumericProbeVariable(variableDimensions[i]));
        newVsize += variableDimensions[i];
    }
    ArrayList<NumericProbeDriver> newDrivers = createDrivers(driverExpressions, newVariables);
    myPropList = createPropertyList(props);
    myConverters = newConverters;
    // myPropValues = new double[props.length][];
    myVariables = newVariables;
    myDrivers = newDrivers;
    if (myNumericList == null || myVsize != newVsize) {
        myVsize = newVsize;
        myNumericList = new NumericList(myVsize);
        myNumericList.setInterpolation(myInterpolation);
        myTmpVec = new VectorNd(myVsize);
    }
    if (traceInfos != null) {
        myPlotTraceManager.rebuild(getPropsOrDimens(), traceInfos);
    } else {
        myPlotTraceManager.rebuild(getPropsOrDimens());
    }
    if (myLegend != null) {
        myLegend.rebuild();
    }
}
Also used : NumericConverter(maspack.properties.NumericConverter) NumericList(maspack.interpolation.NumericList) VectorNd(maspack.matrix.VectorNd)

Example 57 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class AffineNumericInputProbe method setTransform.

// fills in a larger transform
public void setTransform(AffineTransform3d A) {
    int nPoints = myVsize / 3;
    Matrix3dBase Ar = A.getMatrix();
    Vector3d At = A.getOffset();
    for (int i = 0; i < nPoints; i++) {
        R.setSubMatrix(i * 3, i * 3, Ar);
        t.setSubVector(i * 3, new VectorNd(At));
    }
}
Also used : Matrix3dBase(maspack.matrix.Matrix3dBase) Vector3d(maspack.matrix.Vector3d) VectorNd(maspack.matrix.VectorNd)

Example 58 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class AffineNumericInputProbe method getValues.

public VectorNd getValues(double t) {
    VectorNd result = new VectorNd(myVsize);
    double tloc = (t - getStartTime() - timeOffset) / myScale;
    myNumericList.interpolate(result, tloc);
    result = transform(result);
    return result;
}
Also used : VectorNd(maspack.matrix.VectorNd)

Example 59 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class AffineNumericInputProbe method set.

@Override
public void set(Property[] props, String[] driverExpressions, String[] variableNames, int[] variableDimensions, PlotTraceInfo[] traceInfos) {
    super.set(props, driverExpressions, variableNames, variableDimensions, traceInfos);
    myTmpVec = new VectorNd(myVsize);
    initTransform(myVsize);
}
Also used : VectorNd(maspack.matrix.VectorNd)

Example 60 with VectorNd

use of maspack.matrix.VectorNd in project artisynth_core by artisynth.

the class RigidTransformInputProbe method addTransform.

public void addTransform(double t, RigidTransform3d tx) {
    VectorNd posVector = new VectorNd();
    Vector3d offset = tx.getOffset();
    posVector.append(offset.x);
    posVector.append(offset.y);
    posVector.append(offset.z);
    RotationMatrix3d rot = new RotationMatrix3d();
    Vector3d scale = new Vector3d();
    Matrix3d shear = new Matrix3d();
    tx.getMatrixComponents(rot, scale, shear);
    Quaternion q = new Quaternion(rot.getAxisAngle());
    posVector.append(q.s);
    posVector.append(q.u.x);
    posVector.append(q.u.y);
    posVector.append(q.u.z);
    NumericListKnot knot = new NumericListKnot(myVectorSize);
    knot.t = t;
    knot.v.set(posVector);
    myTransAndQuaternParams.add(knot);
    if (t < getStartTime()) {
        setStartTime(t);
    }
    if (t > getStopTime()) {
        setStopTime(t);
    }
}
Also used : RotationMatrix3d(maspack.matrix.RotationMatrix3d) Matrix3d(maspack.matrix.Matrix3d) NumericListKnot(maspack.interpolation.NumericListKnot) Vector3d(maspack.matrix.Vector3d) Quaternion(maspack.matrix.Quaternion) VectorNd(maspack.matrix.VectorNd) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Aggregations

VectorNd (maspack.matrix.VectorNd)136 Point (artisynth.core.mechmodels.Point)29 Point3d (maspack.matrix.Point3d)16 Vector3d (maspack.matrix.Vector3d)15 PointParticleAttachment (artisynth.core.mechmodels.PointParticleAttachment)11 ArrayList (java.util.ArrayList)11 ContactPoint (artisynth.core.mechmodels.ContactPoint)9 MatrixNd (maspack.matrix.MatrixNd)9 Vertex3d (maspack.geometry.Vertex3d)8 SparseMatrixNd (maspack.matrix.SparseMatrixNd)8 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)7 PointAttachment (artisynth.core.mechmodels.PointAttachment)7 PointFem3dAttachment (artisynth.core.femmodels.PointFem3dAttachment)6 FemNode (artisynth.core.femmodels.FemNode)5 PolygonalMesh (maspack.geometry.PolygonalMesh)5 ReaderTokenizer (maspack.util.ReaderTokenizer)5 FemNode3d (artisynth.core.femmodels.FemNode3d)4 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)4 StringReader (java.io.StringReader)4 HashMap (java.util.HashMap)4