use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class RasterExporter method calcNAHelper.
private static NAHelper calcNAHelper(Quadrilateral quad) {
double cx = 0, cy = 0, cz = 0;
boolean nx = true, ny = true, nz = true;
double ulp = Math.ulp(quad.getNodes(0).getX()) * 10;
for (int vrt = 0; vrt < quad.getNodeCount(); vrt++) {
cx += quad.getNodes(vrt).getX();
cy += quad.getNodes(vrt).getY();
cz += quad.getNodes(vrt).getZ();
double xd = Math.abs(quad.getNodes(0).getX() - quad.getNodes(vrt).getX());
double yd = Math.abs(quad.getNodes(0).getY() - quad.getNodes(vrt).getY());
double zd = Math.abs(quad.getNodes(0).getZ() - quad.getNodes(vrt).getZ());
nx = nx && (xd < ulp);
ny = ny && (yd < ulp);
nz = nz && (zd < ulp);
}
Coordinate cm = new Coordinate(cx / quad.getNodeCount(), cy / quad.getNodeCount(), cz / quad.getNodeCount());
int normalAxis = (nx ? Coordinate.X_AXIS : (ny ? Coordinate.Y_AXIS : Coordinate.Z_AXIS));
return new NAHelper(cm, normalAxis);
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class AnalyticCurve method clone.
/**
* Insert the method's description here.
* Creation date: (8/8/00 3:45:00 PM)
* @return java.lang.Object
*/
public Object clone() {
AnalyticCurve ac = (AnalyticCurve) super.clone();
ac.expX = expX;
ac.expY = expY;
ac.expZ = expZ;
ac.offset = new Coordinate(offset.getX(), offset.getY(), offset.getZ());
return ac;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class ControlPointCurve method addOffsetControlPointPrivate.
/**
* Insert the method's description here.
* Creation date: (7/18/00 5:38:25 PM)
* @param offset cbit.vcell.geometry.Coordinate
*/
private void addOffsetControlPointPrivate(Coordinate offset, int controlPointIndex) {
Coordinate oldCoordinate = controlPoints.elementAt(controlPointIndex);
Coordinate newCoordinate = new Coordinate(oldCoordinate.getX() + offset.getX(), oldCoordinate.getY() + offset.getY(), oldCoordinate.getZ() + offset.getZ());
controlPoints.set(controlPointIndex, newCoordinate);
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class ControlPointCurve method pickControlPoint.
/**
* Insert the method's description here.
* Creation date: (7/18/00 4:08:13 PM)
* @return int
* @param point java.awt.Point
*/
public int pickControlPoint(Coordinate pickPoint, double minPickDistance) {
double shortestDistance = Double.MAX_VALUE;
int controlPointIndex = Curve.NONE_SELECTED;
int controlPointCount = getControlPointCount();
for (int i = 0; i < controlPointCount; i++) {
Coordinate controlPointCoord = controlPoints.elementAt(i);
double distance = pickPoint.distanceTo(controlPointCoord);
if (distance <= minPickDistance && distance < shortestDistance) {
controlPointIndex = i;
shortestDistance = distance;
}
}
return controlPointIndex;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class Curve method getAngle.
/*
{
if (sampledCurve == null) {
int sampling = getNumSamplePoints();
if (sampling == DEFAULT_NUM_SAMPLES_FLAG) {
sampling = getDefaultNumSamples();
}
sampledCurve = new SampledCurve(this, sampling);
}
return sampledCurve;
}
*/
/**
* Insert the method's description here.
* Creation date: (7/20/00 1:09:20 PM)
* @return double
* @param vertex cbit.vcell.geometry.Coordinate
* @param p1 cbit.vcell.geometry.Coordinate
* @param p2 cbit.vcell.geometry.Coordinate
*/
public static final double getAngle(Coordinate vertex, Coordinate p1, Coordinate p2) {
// Vector vertex->p1
Coordinate v1 = new Coordinate(p1.getX() - vertex.getX(), p1.getY() - vertex.getY(), p1.getZ() - vertex.getZ());
// Length v1
double v1Length = Math.sqrt(v1.getX() * v1.getX() + v1.getY() * v1.getY() + v1.getZ() * v1.getZ());
// Vector vertex->p2
Coordinate v2 = new Coordinate(p2.getX() - vertex.getX(), p2.getY() - vertex.getY(), p2.getZ() - vertex.getZ());
// Length v2
double v2Length = Math.sqrt(v2.getX() * v2.getX() + v2.getY() * v2.getY() + v2.getZ() * v2.getZ());
// Dot Product v1 and v2
double dotP = (v1.getX() * v2.getX()) + (v1.getY() * v2.getY()) + (v1.getZ() * v2.getZ());
// positive Angle 0->PI
double angle = Math.acos(dotP / (v1Length * v2Length));
// Angle in degrees
return angle * 180 / Math.PI;
}
Aggregations