private void calculateOrigin() { // TODO I am ignoring the possibility of passing in the origin for now and using the dot product calc for non orthoganality. // The origin is perhaps used for cryoEM only and requires orthoganility // CRSSTART is w05_NXSTART, w06_NYSTART, w07_NZSTART // Cell dims w08_MX, w09_MY, w10_MZ; // Map of indices from crs to xyz is w17_MAPC, w18_MAPR, w19_MAPS EdVector vCRS = new EdVector(); for (int i = 0; i < 3; ++i) { int startVal = 0; if (w17_MAPC == i) { startVal = w05_NXSTART; } else if (w18_MAPR == i) { startVal = w06_NYSTART; } else { startVal = w07_NZSTART; } vCRS.vector[i] = startVal; } vCRS.vector[0] /= w08_MX; vCRS.vector[1] /= w09_MY; vCRS.vector[2] /= w10_MZ; _origin = _orthoMat.multiply(vCRS); }
public DensityPoint getCRSFromXYZ(double x, double y, double z) { EdVector vXYZIn = new EdVector(); EdVector vCRS = new EdVector(); vXYZIn.vector[0] = x; vXYZIn.vector[1] = y; vXYZIn.vector[2] = z; //If the axes are all orthogonal if (w14_CELLB_X == 90 && w15_CELLB_Y == 90 && w16_CELLB_Z == 90) { for (int i = 0; i < 3; ++i) { double startVal = vXYZIn.vector[i] - _origin.vector[i]; startVal /= _cellDims[i] / _axisSampling[i]; vCRS.vector[i] = startVal; } } else // they are not orthogonal { EdVector vFraction = _deOrthoMat.multiply(vXYZIn); for (int i = 0; i < 3; ++i) { double val = vFraction.vector[i] * _axisSampling[i] - _crsStart[_map2xyz[i]]; vCRS.vector[i] = val; } } double c = Convert.ToSingle(Math.Round(vCRS.vector[_map2crs[0]], 4)); double r = Convert.ToSingle(Math.Round(vCRS.vector[_map2crs[1]], 4)); double s = Convert.ToSingle(Math.Round(vCRS.vector[_map2crs[2]], 4)); DensityPoint dp = new DensityPoint(c, r, s, 0, "CRS"); return(dp); }