use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SegmentedPlanarConnector method computeRenderVtxs.
protected void computeRenderVtxs(int planeIdx, RigidTransform3d TDW) {
ArrayList<Point3d> segPnts = mySegPlaneCoupling.getSegmentPoints();
if (planeIdx >= segPnts.size() - 1) {
throw new InternalErrorException("index " + planeIdx + " exceeds number of planes");
}
Point3d p0 = segPnts.get(planeIdx);
Point3d p1 = segPnts.get(planeIdx + 1);
Vector3d yaxis = Vector3d.Y_UNIT;
myRenderVtxs[0].set(p0);
myRenderVtxs[0].scaledAdd(-myPlaneSize / 2, yaxis, myRenderVtxs[0]);
myRenderVtxs[3].set(p0);
myRenderVtxs[3].scaledAdd(myPlaneSize / 2, yaxis, myRenderVtxs[3]);
myRenderVtxs[1].set(p1);
myRenderVtxs[1].scaledAdd(-myPlaneSize / 2, yaxis, myRenderVtxs[1]);
myRenderVtxs[2].set(p1);
myRenderVtxs[2].scaledAdd(myPlaneSize / 2, yaxis, myRenderVtxs[2]);
for (int i = 0; i < myRenderVtxs.length; i++) {
myRenderVtxs[i].transform(TDW);
}
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class DistanceGridSurfCalc method computeBCoefs.
public PlaneType computeBCoefs(double[] b, Vector3d r, double[] c, Plane planeCell) {
double rx, ry, rz;
Vector3d nrmCell = planeCell.normal;
double off = planeCell.offset;
PlaneType planeType;
switch(nrmCell.maxAbsIndex()) {
case 0:
{
rx = nrmCell.y / nrmCell.x;
ry = nrmCell.z / nrmCell.x;
rz = off / nrmCell.x;
b[0] = c[1] + c[0] * rx * rx - c[5] * rx;
b[1] = c[2] + c[0] * ry * ry - c[4] * ry;
b[2] = c[3] + 2 * c[0] * rx * ry - c[5] * ry - c[4] * rx;
b[3] = c[7] - 2 * c[0] * rz * rx + c[5] * rz - c[6] * rx;
b[4] = c[8] - 2 * c[0] * rz * ry + c[4] * rz - c[6] * ry;
b[5] = c[9] + c[0] * rz * rz + c[6] * rz;
planeType = PlaneType.YZ;
break;
}
case 1:
{
rx = nrmCell.z / nrmCell.y;
ry = nrmCell.x / nrmCell.y;
rz = off / nrmCell.y;
b[0] = c[2] + c[1] * rx * rx - c[3] * rx;
b[1] = c[0] + c[1] * ry * ry - c[5] * ry;
b[2] = c[4] + 2 * c[1] * rx * ry - c[3] * ry - c[5] * rx;
b[3] = c[8] - 2 * c[1] * rz * rx + c[3] * rz - c[7] * rx;
b[4] = c[6] - 2 * c[1] * rz * ry + c[5] * rz - c[7] * ry;
b[5] = c[9] + c[1] * rz * rz + c[7] * rz;
planeType = PlaneType.ZX;
break;
}
case 2:
{
rx = nrmCell.x / nrmCell.z;
ry = nrmCell.y / nrmCell.z;
rz = off / nrmCell.z;
b[0] = c[0] + c[2] * rx * rx - c[4] * rx;
b[1] = c[1] + c[2] * ry * ry - c[3] * ry;
b[2] = c[5] + 2 * c[2] * rx * ry - c[4] * ry - c[3] * rx;
b[3] = c[6] - 2 * c[2] * rz * rx + c[4] * rz - c[8] * rx;
b[4] = c[7] - 2 * c[2] * rz * ry + c[3] * rz - c[8] * ry;
b[5] = c[9] + c[2] * rz * rz + c[8] * rz;
planeType = PlaneType.XY;
break;
}
default:
{
throw new InternalErrorException("Vector3d.maxAbsIndex() returned value " + nrmCell.maxAbsIndex());
}
}
if (r != null) {
r.x = rx;
r.y = ry;
r.z = rz;
}
return planeType;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class SparseBlockMatrix method clone.
/**
* Creates a clone of this SparseBlockMatrix, along with clones of all the
* associated MatrixBlocks.
*/
public SparseBlockMatrix clone() {
SparseBlockMatrix M;
try {
M = (SparseBlockMatrix) super.clone();
} catch (CloneNotSupportedException e) {
throw new InternalErrorException("clone not supported for super class of SparseBlockMatrix");
}
M.set(this);
return M;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class ComponentPropertyField method valueToText.
protected String valueToText(Object value) {
ModelComponent comp = getComponent(value);
RootModel root = myMain.getRootModel();
if (root == null || comp == null) {
return "";
}
if (value instanceof ModelComponent) {
return ComponentUtils.getPathName(root, comp);
} else if (value instanceof Property) {
Property prop = (Property) value;
boolean excludeLeaf = (myPropertySelector != null && !(prop.get() instanceof CompositeProperty));
String path = ComponentUtils.getPropertyPathName(prop, root, false);
if (!path.contains(":")) {
// root component + property
path = "/:" + path;
}
return path;
} else {
throw new InternalErrorException("Unknown value type: " + value.getClass());
}
// String text = ComponentUtils.getPathName(root, comp);
// if (value instanceof Property)
// { Property prop = (Property)value;
// String propPath = getPropertyPath (prop, myPropertySelector != null);
// if (propPath.length() > 0)
// { text += "/" + propPath;
// }
// }
// return text;
}
use of maspack.util.InternalErrorException in project artisynth_core by artisynth.
the class ComponentPropertyField method setValueFromPropertySelector.
private void setValueFromPropertySelector() {
if (!myPropertyMask) {
String propName = (String) myPropertySelector.getValue();
HasProperties host = getHost();
if (propName.equals(nullString)) {
Object value = getValueForHost();
System.out.println("new value");
updateValueAndDisplay(value);
return;
}
if (host == null) {
throw new InternalErrorException("Current property host is null");
}
Property prop = host.getProperty(propName);
if (prop == null) {
throw new InternalErrorException("Current property host does not contain property " + propName);
}
updateValueAndDisplay(prop);
}
}
Aggregations