Search in sources :

Example 11 with MatrixNd

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

the class MechSystemSolver method preRotate.

private MatrixNd preRotate(MatrixNd M1, RotationMatrix3d[] R) {
    int nbr = R.length;
    MatrixNd MR = new MatrixNd(M1.rowSize(), M1.colSize());
    Vector3d v3 = new Vector3d();
    for (int bi = 0; bi < nbr; bi++) {
        for (int j = 0; j < M1.colSize(); j++) {
            v3.x = M1.get(bi * 3 + 0, j);
            v3.y = M1.get(bi * 3 + 1, j);
            v3.z = M1.get(bi * 3 + 2, j);
            v3.transform(R[bi]);
            MR.set(bi * 3 + 0, j, v3.x);
            MR.set(bi * 3 + 1, j, v3.y);
            MR.set(bi * 3 + 2, j, v3.z);
        }
    }
    return MR;
}
Also used : Vector3d(maspack.matrix.Vector3d) MatrixNd(maspack.matrix.MatrixNd)

Example 12 with MatrixNd

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

the class MechSystemSolver method fullRotate.

private MatrixNd fullRotate(MatrixNd M1, RotationMatrix3d[] R) {
    int nbr = R.length;
    MatrixNd MT = new MatrixNd(M1.rowSize(), M1.colSize());
    MatrixNd MR = new MatrixNd(M1.rowSize(), M1.colSize());
    Vector3d v3 = new Vector3d();
    for (int bi = 0; bi < nbr; bi++) {
        for (int j = 0; j < M1.colSize(); j++) {
            v3.x = M1.get(bi * 3 + 0, j);
            v3.y = M1.get(bi * 3 + 1, j);
            v3.z = M1.get(bi * 3 + 2, j);
            v3.transform(R[bi]);
            MT.set(bi * 3 + 0, j, v3.x);
            MT.set(bi * 3 + 1, j, v3.y);
            MT.set(bi * 3 + 2, j, v3.z);
        }
    }
    for (int bj = 0; bj < nbr; bj++) {
        for (int i = 0; i < M1.rowSize(); i++) {
            v3.x = MT.get(i, bj * 3 + 0);
            v3.y = MT.get(i, bj * 3 + 1);
            v3.z = MT.get(i, bj * 3 + 2);
            v3.transform(R[bj]);
            MR.set(i, bj * 3 + 0, v3.x);
            MR.set(i, bj * 3 + 1, v3.y);
            MR.set(i, bj * 3 + 2, v3.z);
        }
    }
    return MR;
}
Also used : Vector3d(maspack.matrix.Vector3d) MatrixNd(maspack.matrix.MatrixNd)

Example 13 with MatrixNd

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

the class MechSystemSolver method buildA.

private MatrixNd buildA(SparseBlockMatrix S, int sizeS, SparseBlockMatrix GT, int sizeG) {
    MatrixNd A = new MatrixNd(sizeS + sizeG, sizeS + sizeG);
    for (int i = 0; i < sizeS; i++) {
        for (int j = 0; j < sizeS; j++) {
            A.set(i, j, S.get(i, j));
        }
        for (int j = 0; j < sizeG; j++) {
            A.set(i, j + sizeS, GT.get(i, j));
            A.set(j + sizeS, i, GT.get(i, j));
        }
    }
    return A;
}
Also used : MatrixNd(maspack.matrix.MatrixNd)

Example 14 with MatrixNd

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

the class MechSystemBase method printActiveStiffness.

public void printActiveStiffness() throws IOException {
    MatrixNd K = new MatrixNd(getActiveStiffness());
    System.out.println("K=\n" + K.toString("%8.3f"));
}
Also used : MatrixNd(maspack.matrix.MatrixNd)

Example 15 with MatrixNd

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

the class GMLSShapeFunction method computeDM.

@Override
public void computeDM(MatrixNd DM, int dIdx, Point3d pnt, MFreeNode3d[] nodes) {
    MatrixNd cc = new MatrixNd(nBasis, nBasis);
    DM.setSize(nBasis, nBasis);
    DM.setZero();
    int[] derivatives = new int[3];
    derivatives[dIdx] = 1;
    for (MFreeNode3d node : nodes) {
        Point3d pos = node.getRestPosition();
        double w = node.getWeightFunction().evalDerivative(pnt, derivatives);
        for (int i = 0; i <= myOrder; i++) {
            for (int j = 0; j <= myOrder - i; j++) {
                for (int k = 0; k <= myOrder - i - j; k++) {
                    // account for symmetries
                    double d = dcoeff(i, j, k);
                    computeDPCorrelation(cc, pos.x, pos.y, pos.z, i, j, k);
                    DM.scaledAdd(d * w, cc);
                }
            }
        }
    }
}
Also used : MatrixNd(maspack.matrix.MatrixNd) Point3d(maspack.matrix.Point3d)

Aggregations

MatrixNd (maspack.matrix.MatrixNd)37 Point3d (maspack.matrix.Point3d)9 VectorNd (maspack.matrix.VectorNd)9 SparseMatrixNd (maspack.matrix.SparseMatrixNd)4 Vector3d (maspack.matrix.Vector3d)4 LUDecomposition (maspack.matrix.LUDecomposition)3 RigidTransform3d (maspack.matrix.RigidTransform3d)2 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)2 Point (artisynth.core.mechmodels.Point)1 BufferedOutputStream (java.io.BufferedOutputStream)1 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 StringReader (java.io.StringReader)1 Random (java.util.Random)1 CholeskyDecomposition (maspack.matrix.CholeskyDecomposition)1 DenseMatrix (maspack.matrix.DenseMatrix)1 Matrix (maspack.matrix.Matrix)1 Matrix3d (maspack.matrix.Matrix3d)1 Matrix6d (maspack.matrix.Matrix6d)1 Matrix6dBase (maspack.matrix.Matrix6dBase)1