Search in sources :

Example 71 with VectorNd

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

the class VariableVectorField method updateInternalValue.

protected boolean updateInternalValue(Object value) {
    if (!valuesEqual(value, myValue)) {
        if (value instanceof Vector) {
            // make a defensive copy of the
            // supplied vector
            Vector vecValue = (Vector) value;
            if (myResultHolder != null) {
                // use the result holder as the value
                // itself. Reason
                // is that the result holder can be guaranteed to
                // have the Vector sub-type, since it was supplied
                // by the user.
                myResultHolder.set(vecValue);
                value = myResultHolder;
            } else {
                // make a defensive copy of the supplied vector
                value = new VectorNd(vecValue);
            }
        }
        myValue = value;
        return true;
    } else {
        return false;
    }
}
Also used : VectorNd(maspack.matrix.VectorNd) Vector(maspack.matrix.Vector)

Example 72 with VectorNd

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

the class VectorField method setVectorSize.

/**
 * Sets the size of the vector associated with this vector field. Changing
 * the vector size will cause the result holder to be cleared, and the
 * current vector value to be reset to a zero vector of the indicated size.
 * The number of columns in the field will also be reset.
 *
 * @param size
 * new vector size
 */
public void setVectorSize(int size) {
    if (size < 1) {
        throw new IllegalArgumentException("size must be greater than 1");
    }
    if (size != myVectorSize) {
        setColumns(5 * size);
        myResultHolder = null;
        myVectorSize = size;
        setValue(new VectorNd(size));
    }
}
Also used : VectorNd(maspack.matrix.VectorNd)

Example 73 with VectorNd

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

the class VectorField method textToValue.

public Object textToValue(String text, BooleanHolder corrected, StringHolder errMsg) {
    corrected.value = false;
    if (isBlank(text)) {
        return setVoidIfPossible(errMsg);
    }
    ReaderTokenizer rtok = new ReaderTokenizer(new StringReader(text));
    VectorNd tmp = new VectorNd(myVectorSize);
    try {
        for (int i = 0; i < myVectorSize; i++) {
            if (rtok.nextToken() != ReaderTokenizer.TT_NUMBER) {
                if (rtok.ttype == ReaderTokenizer.TT_EOF) {
                    return illegalValue("Missing elements (there should be " + myVectorSize + ")", errMsg);
                } else {
                    return illegalValue("Malformed number for element " + i, errMsg);
                }
            }
            tmp.set(i, rtok.nval);
        }
        if (rtok.nextToken() != ReaderTokenizer.TT_EOF) {
            if (rtok.ttype == ReaderTokenizer.TT_NUMBER) {
                return illegalValue("Too many elements (there should be " + myVectorSize + ")", errMsg);
            } else {
                return illegalValue("Extra characters after last element", errMsg);
            }
        }
        return validValue(tmp, errMsg);
    } catch (Exception e) {
        return illegalValue("Improperly formed vector", errMsg);
    }
}
Also used : ReaderTokenizer(maspack.util.ReaderTokenizer) StringReader(java.io.StringReader) VectorNd(maspack.matrix.VectorNd)

Example 74 with VectorNd

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

the class VectorMultiField method updateInternalValue.

protected boolean updateInternalValue(Object value) {
    if (!valuesEqual(value, myValue)) {
        if (value instanceof Vector) {
            // make a defensive copy of the
            // supplied vector
            VectorNd vecValue = new VectorNd((Vector) value);
            if (myResultHolder != null) {
                for (int i = 0; i < myVectorSize; i++) {
                    myResultHolder.set(i, vecValue.get(i));
                }
            }
            value = vecValue;
        }
        myValue = value;
        return true;
    } else {
        return false;
    }
}
Also used : VectorNd(maspack.matrix.VectorNd) Vector(maspack.matrix.Vector)

Example 75 with VectorNd

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

the class SymmetricMatrix3dField method textToValue.

public Object textToValue(String text, BooleanHolder corrected, StringHolder errMsg) {
    corrected.value = false;
    Object value = super.textToValue(text, corrected, errMsg);
    if (value == Property.IllegalValue) {
        return Property.IllegalValue;
    }
    if (value instanceof VectorNd) {
        VectorNd tmp = (VectorNd) value;
        value = new SymmetricMatrix3d(tmp.get(0), tmp.get(1), tmp.get(2), tmp.get(3), tmp.get(4), tmp.get(5));
    }
    return validValue(value, errMsg);
}
Also used : SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) VectorNd(maspack.matrix.VectorNd)

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