use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CurveRenderer method updateOriginAndScaling2D.
/**
* Insert the method's description here.
* Creation date: (10/16/00 6:45:56 PM)
*/
private void updateOriginAndScaling2D() {
//
if (getWorldDelta() == null) {
setScaling2D(null);
} else {
Coordinate wd = getWorldDelta();
double wd_x = Coordinate.convertAxisFromStandardXYZToNormal(wd.getX(), wd.getY(), wd.getZ(), Coordinate.X_AXIS, getNormalAxis());
double wd_y = Coordinate.convertAxisFromStandardXYZToNormal(wd.getX(), wd.getY(), wd.getZ(), Coordinate.Y_AXIS, getNormalAxis());
setScaling2D(new Point2D.Double(1 / wd_x, 1 / wd_y));
}
//
if (getWorldOrigin() == null || getWorldDelta() == null) {
setOrigin2D(null);
} else {
Point2D.Double origin2DScaled = CurveRendererCurveInfo.projectAndScale3DPoint(getWorldOrigin(), getNormalAxis(), getScaling2D());
setOrigin2D(origin2DScaled);
}
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CurveRenderer method setWorldOrigin.
/**
* Sets the worldDelta property (cbit.vcell.geometry.Coordinate) value.
* @param worldDelta The new value for the property.
* @see #getWorldDelta
*/
public void setWorldOrigin(org.vcell.util.Coordinate wo) {
if (wo == null && fieldWorldOrigin == null) {
return;
}
Coordinate oldValue = fieldWorldOrigin;
fieldWorldOrigin = wo;
updateOriginAndScaling2D();
firePropertyChange("worldOrigin", oldValue, wo);
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class XmlReader method getCoordinate.
/**
* This method returns a Coordinate object from a XML Element.
* Creation date: (5/22/2001 5:53:05 PM)
* @return cbit.vcell.geometry.Coordinate
* @param param org.jdom.Element
*/
public Coordinate getCoordinate(Element param) {
// get attributes
double x = Double.parseDouble(param.getAttributeValue(XMLTags.XAttrTag));
double y = Double.parseDouble(param.getAttributeValue(XMLTags.YAttrTag));
double z = Double.parseDouble(param.getAttributeValue(XMLTags.ZAttrTag));
// **** create coordinate ***
Coordinate coord = new Coordinate(x, y, z);
return coord;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class MathTestingUtilities method resample3DSpatial.
/**
* Insert the method's description here.
* Creation date: (10/27/2003 5:07:42 PM)
* @return double[]
* @param data double[]
* @param sourceMesh cbit.vcell.solvers.CartesianMesh
* @param targetMesh cbit.vcell.solvers.CartesianMesh
*/
public static double[] resample3DSpatial(double[] sourceData, CartesianMesh sourceMesh, CartesianMesh refMesh) {
if (sourceData.length != sourceMesh.getNumVolumeElements()) {
throw new RuntimeException("must be volume data, data length doesn't match number of volume elements");
}
// for volume samples:
//
// loop through volumeIndexes from refMesh
// Coordinate refCoordinate = refMesh.getCoordinate(volumeIndex);
// Coordinate fractionalIndex = sourceMesh.getFractionCoordinateIndex(Coordinate refCoordinate);
// ....interpolate in z
// start with integer portion of fractionIndex
double[] resampledData = new double[refMesh.getSizeX() * refMesh.getSizeY() * refMesh.getSizeZ()];
for (int i = 0; i < resampledData.length; i++) {
Coordinate refCoordinate = refMesh.getCoordinateFromVolumeIndex(i);
Coordinate fractionalIndex = sourceMesh.getFractionalCoordinateIndex(refCoordinate);
int ceil_x;
int floor_x;
int ceil_y;
int floor_y;
int ceil_z;
int floor_z;
if (fractionalIndex.getX() < 0) {
floor_x = 0;
ceil_x = 1;
} else if (fractionalIndex.getX() > sourceMesh.getSizeX() - 1) {
floor_x = sourceMesh.getSizeX() - 2;
ceil_x = sourceMesh.getSizeX() - 1;
} else {
ceil_x = (int) Math.ceil(fractionalIndex.getX());
floor_x = (int) Math.floor(fractionalIndex.getX());
}
if (fractionalIndex.getY() < 0) {
floor_y = 0;
ceil_y = 1;
} else if (fractionalIndex.getY() > sourceMesh.getSizeY() - 1) {
floor_y = sourceMesh.getSizeY() - 2;
ceil_y = sourceMesh.getSizeY() - 1;
} else {
ceil_y = (int) Math.ceil(fractionalIndex.getY());
floor_y = (int) Math.floor(fractionalIndex.getY());
}
if (fractionalIndex.getZ() < 0) {
floor_z = 0;
ceil_z = 1;
} else if (fractionalIndex.getZ() > sourceMesh.getSizeZ() - 1) {
floor_z = sourceMesh.getSizeZ() - 2;
ceil_z = sourceMesh.getSizeZ() - 1;
} else {
ceil_z = (int) Math.ceil(fractionalIndex.getZ());
floor_z = (int) Math.floor(fractionalIndex.getZ());
}
double fract_x = fractionalIndex.getX() - floor_x;
double fract_y = fractionalIndex.getY() - floor_y;
double fract_z = fractionalIndex.getZ() - floor_z;
CoordinateIndex coord_1 = new CoordinateIndex(floor_x, floor_y, floor_z);
CoordinateIndex coord_2 = new CoordinateIndex(ceil_x, floor_y, floor_z);
CoordinateIndex coord_3 = new CoordinateIndex(floor_x, floor_y, ceil_z);
CoordinateIndex coord_4 = new CoordinateIndex(ceil_x, floor_y, ceil_z);
CoordinateIndex coord_5 = new CoordinateIndex(floor_x, ceil_y, ceil_z);
CoordinateIndex coord_6 = new CoordinateIndex(ceil_x, ceil_y, ceil_z);
CoordinateIndex coord_7 = new CoordinateIndex(floor_x, ceil_y, floor_z);
CoordinateIndex coord_8 = new CoordinateIndex(ceil_x, ceil_y, floor_z);
int volIndx1 = sourceMesh.getVolumeIndex(coord_1);
int volIndx2 = sourceMesh.getVolumeIndex(coord_2);
int volIndx3 = sourceMesh.getVolumeIndex(coord_3);
int volIndx4 = sourceMesh.getVolumeIndex(coord_4);
int volIndx5 = sourceMesh.getVolumeIndex(coord_5);
int volIndx6 = sourceMesh.getVolumeIndex(coord_6);
int volIndx7 = sourceMesh.getVolumeIndex(coord_7);
int volIndx8 = sourceMesh.getVolumeIndex(coord_8);
// use it to compute a, b, c, d, then e & f ** Interpolation in X **
if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) != refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx2 = volIndx1;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) == refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx1 = volIndx2;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx1) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx2) != refMesh.getSubVolumeFromVolumeIndex(i)) {
throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
}
if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) != refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx4 = volIndx3;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) == refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx3 = volIndx4;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx3) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx4) != refMesh.getSubVolumeFromVolumeIndex(i)) {
throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
}
if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) != refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx6 = volIndx5;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) == refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx5 = volIndx6;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx5) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx6) != refMesh.getSubVolumeFromVolumeIndex(i)) {
throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
}
if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) == refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) != refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx8 = volIndx7;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) == refMesh.getSubVolumeFromVolumeIndex(i)) {
volIndx7 = volIndx8;
} else if (sourceMesh.getSubVolumeFromVolumeIndex(volIndx7) != refMesh.getSubVolumeFromVolumeIndex(i) && sourceMesh.getSubVolumeFromVolumeIndex(volIndx8) != refMesh.getSubVolumeFromVolumeIndex(i)) {
throw new RuntimeException("Either subvolume in sourceMesh not equal to refMesh subVol cannot be handled at this time!");
}
double val_a = sourceData[volIndx1] + fract_x * (sourceData[volIndx2] - sourceData[volIndx1]);
double val_b = sourceData[volIndx3] + fract_x * (sourceData[volIndx4] - sourceData[volIndx3]);
double val_c = sourceData[volIndx5] + fract_x * (sourceData[volIndx6] - sourceData[volIndx5]);
double val_d = sourceData[volIndx7] + fract_x * (sourceData[volIndx8] - sourceData[volIndx7]);
// Interpolate in Y
double val_e = val_a + fract_y * (val_d - val_a);
double val_f = val_b + fract_y * (val_c - val_b);
// Interpolate in Z - final resampledSourceData value
resampledData[i] = val_e + fract_z * (val_f - val_e);
}
return resampledData;
}
use of org.vcell.util.Coordinate in project vcell by virtualcell.
the class CartesianMesh method getCoordinateFromContourIndex.
/**
* This method was created in VisualAge.
* @return cbit.vcell.geometry.Coordinate
* @param coordIndex cbit.vcell.math.CoordinateIndex
*/
public Coordinate getCoordinateFromContourIndex(int contourIndex) {
ContourElement ce = getContourElements()[contourIndex];
Coordinate begCoord = ce.getBeginCoordinate();
Coordinate endCoord = ce.getEndCoordinate();
return (new Coordinate(0.5 * (begCoord.getX() + endCoord.getX()), 0.5 * (begCoord.getY() + endCoord.getY()), 0.5 * (begCoord.getZ() + endCoord.getZ())));
}
Aggregations