Search in sources :

Example 46 with Matrix3d

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

the class MFreeFactory method distributeIPointsFromMap.

// public static void distributePairedIPoints(MFreeElement3d[] elemList,
// MFreeIntegrationPoint3d[] ipnts,
// IntegrationData3d[] idata, BVTree elemTree, double tol) {
// 
// for (int i = 0; i < ipnts.length; i++) {
// MFreeIntegrationPoint3d ipnt = ipnts[i];
// IntegrationData3d idat = null;
// if (idata != null) {
// idat = idata[i];
// } else {
// idat = new IntegrationData3d();
// idat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
// }
// 
// ArrayList<MFreeElement3d> celems =
// findPairedElementsContaining(ipnt.getPosition(), elemTree, tol);
// for (MFreeElement3d elem : celems) {
// elem.addIntegrationPoint(ipnt, idat, ipnt.getWeight(), false);
// }
// }
// 
// for (MFreeElement3d elem : elemList) {
// elem.updateAllVolumes();
// }
// 
// }
private static void distributeIPointsFromMap(HashMap<MFreeIntegrationPoint3d, MFreeElement3d> pntMap) {
    for (MFreeIntegrationPoint3d ipnt : pntMap.keySet()) {
        IntegrationData3d idat = new IntegrationData3d();
        idat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
        MFreeElement3d elem = pntMap.get(ipnt);
        elem.addIntegrationPoint(ipnt, idat, ipnt.getWeight(), false);
    }
    for (MFreeElement3d elem : pntMap.values()) {
        elem.updateAllVolumes();
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) IntegrationData3d(artisynth.core.femmodels.IntegrationData3d)

Example 47 with Matrix3d

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

the class MFreeFactory method addWarpingPoints.

// public static void distributePartitionedIPoints(
// DirectedGraph<MFreeElement3d,MFreeNode3d> connectivity,
// MFreeIntegrationPoint3d[] ipnts,
// IntegrationData3d[] idata, BVTree elemTree, double tol) {
// 
// for (int i = 0; i < ipnts.length; i++) {
// MFreeIntegrationPoint3d ipnt = ipnts[i];
// IntegrationData3d idat = null;
// if (idata != null) {
// idat = idata[i];
// } else {
// idat = new IntegrationData3d();
// idat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
// }
// 
// ArrayList<MFreeElement3d> celems =
// findPartitionedElementsContaining(
// ipnt.getPosition(), connectivity, elemTree, tol);
// for (MFreeElement3d elem : celems) {
// elem.addIntegrationPoint(ipnt, idat, ipnt.getWeight(), false);
// }
// }
// 
// for (Vertex<MFreeElement3d,MFreeNode3d> vtx : connectivity.getVertices()) {
// MFreeElement3d elem = vtx.getData();
// if (elem != null) {
// elem.updateAllVolumes();
// }
// }
// 
// }
private static void addWarpingPoints(List<MFreeElement3d> elems, BVTree nodeTree) {
    for (MFreeElement3d elem : elems) {
        MFreeIntegrationPoint3d wpnt = createWarpingPoint(elem, null, nodeTree);
        IntegrationData3d wdat = new IntegrationData3d();
        wdat.setRestInverseJacobian(new Matrix3d(Matrix3d.IDENTITY), 1);
        elem.setWarpingPoint(wpnt, wdat);
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) IntegrationData3d(artisynth.core.femmodels.IntegrationData3d)

Example 48 with Matrix3d

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

the class MFreeMuscleModel method render.

// public void setDrawFibers(boolean enable) {
// myDrawFibers = enable;
// }
public void render(Renderer renderer, int flags) {
    super.render(renderer, flags);
    // if (myFiberMesh != null) {
    // myFiberMesh.render(renderer, myRenderProps, /* flags= */0);
    // }
    // if (myDrawFibers) {
    RenderProps fiberRenderProps = myFiberRenderProps;
    if (fiberRenderProps == null) {
        fiberRenderProps = DEFAULT_FIBER_RENDER_PROPS;
    }
    double dirLen = getDirectionRenderLen();
    if (dirLen > 0) {
        Matrix3d F = new Matrix3d();
        Vector3d dir = new Vector3d();
        float[] coords0 = new float[3];
        float[] coords1 = new float[3];
        for (FemElement3d e : getElements()) {
            renderDirection(renderer, fiberRenderProps, e, coords0, coords1, F, dir, dirLen);
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) FemElement3d(artisynth.core.femmodels.FemElement3d) Vector3d(maspack.matrix.Vector3d) RenderProps(maspack.render.RenderProps)

Example 49 with Matrix3d

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

the class MFreeMuscleModel method renderIPointDirection.

protected void renderIPointDirection(Renderer renderer, RenderProps props, FemElement3d elem, float[] coords0, float[] coords1, Matrix3d F, Vector3d dir, double len) {
    IntegrationPoint3d[] ipnt = elem.getIntegrationPoints();
    IntegrationData3d[] idata = elem.getIntegrationData();
    for (int i = 0; i < ipnt.length; i++) {
        Matrix3d Frame = idata[i].getFrame();
        if (Frame != null) {
            dir.x = Frame.m00;
            dir.y = Frame.m10;
            dir.z = Frame.m20;
            ipnt[i].computeGradientForRender(F, elem.getNodes(), idata[i].getInvJ0());
            ipnt[i].computeCoordsForRender(coords0, elem.getNodes());
            F.mul(dir, dir);
            dir.scale(len);
            coords0[0] -= (float) dir.x / 2;
            coords0[1] -= (float) dir.y / 2;
            coords0[2] -= (float) dir.z / 2;
            coords1[0] = coords0[0] + (float) dir.x;
            coords1[1] = coords0[1] + (float) dir.y;
            coords1[2] = coords0[2] + (float) dir.z;
            props.getLineColor(myDirectionColor);
            renderer.drawLine(props, coords0, coords1, myDirectionColor, /*capped=*/
            false, /*highlight=*/
            false);
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) IntegrationPoint3d(artisynth.core.femmodels.IntegrationPoint3d) IntegrationData3d(artisynth.core.femmodels.IntegrationData3d)

Example 50 with Matrix3d

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

the class PointDistributor method getPrincipalAxes.

public static RigidTransform3d getPrincipalAxes(PolygonalMesh mesh) {
    Vector3d mov1 = new Vector3d();
    Vector3d mov2 = new Vector3d();
    Vector3d pov = new Vector3d();
    double vol = mesh.computeVolumeIntegrals(mov1, mov2, pov);
    double mass = vol;
    Point3d cov = new Point3d();
    // center of volume
    cov.scale(1.0 / vol, mov1);
    // [c], skew symmetric
    Matrix3d covMatrix = new Matrix3d(0, -cov.z, cov.y, cov.z, 0, -cov.x, -cov.y, cov.x, 0);
    // J
    Matrix3d J = new Matrix3d((mov2.y + mov2.z), -pov.z, -pov.y, -pov.z, (mov2.x + mov2.z), -pov.x, -pov.y, -pov.x, (mov2.x + mov2.y));
    // Jc = J + m[c][c]
    Matrix3d Jc = new Matrix3d();
    Jc.mul(covMatrix, covMatrix);
    Jc.scale(mass);
    Jc.add(J);
    // Compute eigenvectors and eigenvlaues of Jc
    SymmetricMatrix3d JcSymmetric = new SymmetricMatrix3d(Jc);
    Vector3d lambda = new Vector3d();
    Matrix3d U = new Matrix3d();
    JcSymmetric.getEigenValues(lambda, U);
    // Construct the rotation matrix
    RotationMatrix3d R = new RotationMatrix3d();
    R.set(U);
    lambda.absolute();
    if (lambda.x > lambda.y && lambda.z > lambda.y) {
        R.rotateZDirection(new Vector3d(R.m01, R.m11, R.m21));
    } else if (lambda.x > lambda.z && lambda.y > lambda.z) {
        R.rotateZDirection(new Vector3d(R.m00, R.m10, R.m20));
    }
    return (new RigidTransform3d(cov, R));
}
Also used : RigidTransform3d(maspack.matrix.RigidTransform3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d) Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d) Point3d(maspack.matrix.Point3d) SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d)

Aggregations

Matrix3d (maspack.matrix.Matrix3d)64 SymmetricMatrix3d (maspack.matrix.SymmetricMatrix3d)42 Vector3d (maspack.matrix.Vector3d)32 RotationMatrix3d (maspack.matrix.RotationMatrix3d)22 Matrix6d (maspack.matrix.Matrix6d)15 Point3d (maspack.matrix.Point3d)9 RigidTransform3d (maspack.matrix.RigidTransform3d)7 SVDecomposition3d (maspack.matrix.SVDecomposition3d)7 IntegrationData3d (artisynth.core.femmodels.IntegrationData3d)6 AffineTransform3d (maspack.matrix.AffineTransform3d)4 VectorNd (maspack.matrix.VectorNd)4 IntegrationPoint3d (artisynth.core.femmodels.IntegrationPoint3d)3 SolidDeformation (artisynth.core.materials.SolidDeformation)3 FemMaterial (artisynth.core.materials.FemMaterial)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 BVNode (maspack.geometry.BVNode)2 BVTree (maspack.geometry.BVTree)2 Boundable (maspack.geometry.Boundable)2 LineSegment (maspack.geometry.LineSegment)2