public void setData(int x, int y, int z, DarkFieldPCA myPCA) { SimpleMatrix eigenVectors = myPCA.getEigenVectors(); SimpleVector eigenValues = myPCA.getEigenValues(); for (int i = 0; i < fieldList.size(); i++) { SimpleVector eigenVec = eigenVectors.getCol(i); double eigenVal = eigenValues.getElement(i); eigenVec = eigenVec.multipliedBy(eigenVal); fieldList.get(i).setVector(x, y, z, eigenVec); } // /** // * Threshold that checks, if 3 component of eigenvalues is too small // * If 3 component is too small, don't consider it as a fiber orientation // * and ignore it // */ // double th = 1E-10; // SimpleVector fiberDir; // if(myPCA.getEigenValues().getElement(2)<th){ // fiberDir = new SimpleVector(3); // }else{ // fiberDir = myPCA.getEigenVectors().getCol(2).normalizedL2(); // fiberDir.multiplyBy(myPCA.getEigenValues().getElement(2)); // } }
private void followRay( SimpleVector pos, SimpleVector dir, double energyEV, FloatProcessor imp, int scatterCount, double totalDistance) { if (energyEV <= 1 || scatterCount > 20000) { System.out.println("energy low, times scattered: " + scatterCount); return; } // follow ray until next interaction point SimpleVector oldPos = pos.clone(); double dist = sampler.getDistanceUntilNextInteractionCm(material, energyEV); pos.add(dir.multipliedBy(dist)); pathlengths.add(dist); // draw the entire path // imp.drawLine((int)(scale*oldPos.getElement(0)), (int)(scale*oldPos.getElement(1)), // (int)(scale*pos.getElement(0)), (int)(scale*pos.getElement(1))); // draw interaction points only imp.drawDot((int) (scale * pos.getElement(0)), (int) (scale * pos.getElement(1))); // choose compton or photoelectric effect double photo = material.getAttenuation(energyEV / 1000, AttenuationType.PHOTOELECTRIC_ABSORPTION); double compton = material.getAttenuation(energyEV / 1000, AttenuationType.INCOHERENT_ATTENUATION); if (sampler.random() * (photo + compton) <= photo) { // photoelectric absorption energyEV = 0; // System.out.println("absorbed after " + scatterCount + " collisions"); xs.add(pos.getElement(0)); ys.add(pos.getElement(1)); zs.add(pos.getElement(2)); return; } else { // compton scattering energyEV = sampler.sampleComptonScattering(energyEV, dir); // send new ray followRay(pos, dir, energyEV, imp, scatterCount + 1, totalDistance + dist); } }
public void setTrajectory( int numProjectionMatrices, double sourceToAxisDistance, double averageAngularIncrement, double detectorOffsetX, double detectorOffsetY, CameraAxisDirection uDirection, CameraAxisDirection vDirection, SimpleVector rotationAxis, PointND rotationCenter, double angleFirstProjection) { this.projectionMatrices = new Projection[numProjectionMatrices]; this.primaryAngles = new double[numProjectionMatrices]; this.numProjectionMatrices = numProjectionMatrices; this.sourceToAxisDistance = sourceToAxisDistance; this.averageAngularIncrement = averageAngularIncrement; this.detectorOffsetU = detectorOffsetX; this.detectorOffsetV = detectorOffsetY; double cosPhi = Math.cos(General.toRadians(angleFirstProjection)); double sinPhi = Math.sin(General.toRadians(angleFirstProjection)); SimpleMatrix rotMat = new SimpleMatrix(3, 3); rotMat.setElementValue(0, 0, cosPhi); rotMat.setElementValue(0, 1, sinPhi); rotMat.setElementValue(1, 0, -sinPhi); rotMat.setElementValue(1, 1, cosPhi); rotMat.setElementValue(2, 2, 1); SimpleVector centerToCameraIdealAtInitialAngle = SimpleOperators.multiply(rotMat, new SimpleVector(sourceToAxisDistance, 0, 0)); Plane3D trajPlane = new Plane3D( rotationAxis, SimpleOperators.multiplyInnerProd(rotationAxis, rotationCenter.getAbstractVector())); double distToPlane = trajPlane.computeDistance(new PointND(centerToCameraIdealAtInitialAngle)); SimpleVector centerToCameraDir = SimpleOperators.subtract( SimpleOperators.add( rotationAxis.multipliedBy(-1 * distToPlane), centerToCameraIdealAtInitialAngle), rotationCenter.getAbstractVector()); centerToCameraDir.divideBy(centerToCameraDir.normL2()); SimpleVector centerToCameraInitialInPlane = centerToCameraDir.multipliedBy(sourceToAxisDistance); for (int i = 0; i < numProjectionMatrices; i++) { primaryAngles[i] = i * averageAngularIncrement + angleFirstProjection; // System.out.println(primaryAngles[i] + " " + averageAngularIncrement + " " + // this.reconDimensions[0] + " " + this.reconDimensions[1]); projectionMatrices[i] = new Projection(); double rotationAngle = General.toRadians(primaryAngles[i]); projectionMatrices[i].setRtFromCircularTrajectory( rotationCenter.getAbstractVector(), rotationAxis, sourceToAxisDistance, centerToCameraInitialInPlane, uDirection, vDirection, rotationAngle); SimpleVector spacingUV = new SimpleVector(pixelDimensionX, pixelDimensionY); SimpleVector sizeUV = new SimpleVector(detectorWidth, detectorHeight); SimpleVector offset = new SimpleVector(detectorOffsetX, detectorOffsetY); projectionMatrices[i].setKFromDistancesSpacingsSizeOffset( sourceToDetectorDistance, spacingUV, sizeUV, offset, 1.0, 0); } this.projectionStackSize = numProjectionMatrices; // System.out.println("Defined geometry with SDD " +sourceToDetectorDistance); }