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);
}
}
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;
}
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);
}
}
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);
}
}
}
}
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));
}
}
Aggregations