Search in sources :

Example 41 with Matrix3d

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

the class FemMuscleModel method renderElementDirection.

protected void renderElementDirection(Renderer renderer, RenderProps props, FemElement3d elem, float[] coords0, float[] coords1, Matrix3d F, Vector3d dir, double len) {
    IntegrationData3d[] idata = elem.getIntegrationData();
    elem.computeRenderCoordsAndGradient(F, coords0);
    int ndirs = 0;
    dir.setZero();
    for (int i = 0; i < idata.length; i++) {
        Matrix3d Frame = idata[i].myFrame;
        if (Frame != null) {
            dir.x += Frame.m00;
            dir.y += Frame.m10;
            dir.z += Frame.m20;
            ndirs++;
        }
    }
    if (ndirs > 0) {
        dir.normalize();
        F.mul(dir, dir);
        double size = elem.computeDirectedRenderSize(dir);
        dir.scale(0.5 * size);
        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)

Example 42 with Matrix3d

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

the class LinearMaterialCache method maxDistance.

public double maxDistance(LinearMaterialCache cache) {
    double maxdist = 0;
    Matrix3d diff = new Matrix3d();
    Vector3d dvec = new Vector3d();
    if (cache.K0.length != K0.length) {
        return Double.POSITIVE_INFINITY;
    }
    for (int i = 0; i < K0.length; ++i) {
        if (cache.K0[i].length != K0[i].length) {
            return Double.POSITIVE_INFINITY;
        }
        for (int j = 0; j < K0[i].length; ++j) {
            diff.sub(K0[i][j], cache.K0[i][j]);
            double dist = diff.maxNorm();
            if (dist > maxdist) {
                maxdist = dist;
            }
        }
    }
    if (cache.f0.length != f0.length) {
        return Double.POSITIVE_INFINITY;
    }
    for (int i = 0; i < f0.length; ++i) {
        dvec.sub(f0[i], cache.f0[i]);
        double dist = dvec.oneNorm();
        if (dist > maxdist) {
            maxdist = dist;
        }
    }
    return maxdist;
}
Also used : SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d)

Example 43 with Matrix3d

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

the class MuscleElementDesc method render.

public void render(Renderer renderer, RenderProps props, int flags) {
    double widgetSize = 0;
    double directionLength = 0;
    ModelComponent gparent = getGrandParent();
    DirectionRenderType renderType = DirectionRenderType.ELEMENT;
    if (gparent instanceof MuscleBundle) {
        MuscleBundle bundle = (MuscleBundle) gparent;
        widgetSize = bundle.getElementWidgetSize();
        directionLength = bundle.getDirectionRenderLen();
        renderType = bundle.getDirectionRenderType();
    }
    if (widgetSize != 0) {
        Shading savedShading = renderer.setPropsShading(props);
        if (myWidgetColor != null) {
            renderer.setFaceColoring(props, myWidgetColor, isSelected());
        } else {
            renderer.setFaceColoring(props, isSelected());
        }
        myElement.renderWidget(renderer, widgetSize, props);
        renderer.setShading(savedShading);
    }
    if (directionLength > 0) {
        Matrix3d F = new Matrix3d();
        Vector3d dir = new Vector3d();
        float[] coords0 = new float[3];
        float[] coords1 = new float[3];
        renderDirection(renderer, props, coords0, coords1, F, dir, directionLength, renderType);
    }
}
Also used : SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) Matrix3d(maspack.matrix.Matrix3d) ModelComponent(artisynth.core.modelbase.ModelComponent) DirectionRenderType(artisynth.core.femmodels.MuscleBundle.DirectionRenderType) Vector3d(maspack.matrix.Vector3d) Shading(maspack.render.Renderer.Shading)

Example 44 with Matrix3d

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

the class MuscleElementDescList method renderDirections.

private void renderDirections(Renderer renderer, double len, DirectionRenderType type, boolean selected) {
    Matrix3d F = new Matrix3d();
    Vector3d dir = new Vector3d();
    float[] coords0 = new float[3];
    float[] coords1 = new float[3];
    for (int i = 0; i < size(); i++) {
        MuscleElementDesc desc = get(i);
        if (desc.getRenderProps() == null && desc.isSelected() == selected) {
            if (renderer.isSelecting()) {
                if (renderer.isSelectable(desc)) {
                    renderer.beginSelectionQuery(i + size());
                    desc.renderDirection(renderer, myRenderProps, coords0, coords1, F, dir, len, type);
                    renderer.endSelectionQuery();
                }
            } else {
                desc.renderDirection(renderer, myRenderProps, coords0, coords1, F, dir, len, type);
            }
        }
    }
}
Also used : Matrix3d(maspack.matrix.Matrix3d) Vector3d(maspack.matrix.Vector3d)

Example 45 with Matrix3d

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

the class StiffnessWarper3d method addNodeStiffness.

/**
 * Adds the total stiffness contributions between nodes i and j
 * from all cached linear and corotated linear materials to the given
 * matrix
 *
 * @param K local stiffness matrix
 * @param i first node index
 * @param j second node index
 */
public void addNodeStiffness(Matrix3d K, int i, int j) {
    // corotated component
    if (corotated != null) {
        Matrix3d Kr = new Matrix3d();
        rotateStiffness(Kr, corotated.getInitialStiffness(i, j));
        K.add(Kr);
    }
    // linear component
    if (linear != null) {
        K.add(linear.getInitialStiffness(i, j));
    }
}
Also used : SymmetricMatrix3d(maspack.matrix.SymmetricMatrix3d) RotationMatrix3d(maspack.matrix.RotationMatrix3d) Matrix3d(maspack.matrix.Matrix3d)

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