Exemplo n.º 1
0
  /**
   * method to calculate a mapping K from two source positions C0, C1 to a plane C0 (C1) is the
   * source position from the first (second) view
   */
  public void createMappingToEpipolarPlane() {

    // set up source matrices //
    SimpleVector C0 = this.view1.C;
    SimpleVector C1 = this.view2.C;

    // compute Pluecker coordinates //
    double L01 = C0.getElement(0) * C1.getElement(1) - C0.getElement(1) * C1.getElement(0);
    double L02 = C0.getElement(0) * C1.getElement(2) - C0.getElement(2) * C1.getElement(0);
    double L03 = C0.getElement(0) * C1.getElement(3) - C0.getElement(3) * C1.getElement(0);
    double L12 = C0.getElement(1) * C1.getElement(2) - C0.getElement(2) * C1.getElement(1);
    double L13 = C0.getElement(1) * C1.getElement(3) - C0.getElement(3) * C1.getElement(1);
    double L23 = C0.getElement(2) * C1.getElement(3) - C0.getElement(3) * C1.getElement(2);

    // construct B (6x1) //
    SimpleVector B = new SimpleVector(L01, L02, L03, L12, L13, L23);

    // compute infinity point in direction of B //
    SimpleVector N = new SimpleVector(-L03, -L13, -L23, 0);

    // compute plane E0 containing B and X0=(0,0,0,1) //
    SimpleVector E0 = SimpleOperators.getPlueckerJoin(B, new SimpleVector(0, 0, 0, 1));

    // find othonormal basis from plane normals //
    // (vectors are of 3x1)
    SimpleVector a2 = new SimpleVector(E0.getElement(0), E0.getElement(1), E0.getElement(2));
    SimpleVector a3 = new SimpleVector(N.getElement(0), N.getElement(1), N.getElement(2));
    // set vectors to unit length
    a2.normalizeL2();
    a3.normalizeL2();

    // calculate cross product to get the last basis vector //
    SimpleVector a1 = General.crossProduct(a2, a3).negated();
    // (a1 is already of unit length -> no normalization needed)

    // set up assembly matrix A (4x3) //
    SimpleMatrix A = new SimpleMatrix(4, 3);
    A.setSubColValue(0, 0, a1);
    A.setSubColValue(0, 1, a2);
    A.setSubColValue(0, 2, C0);

    // store mapping matrix K (4x3 = 4x4 * 4x3) //
    this.K = SimpleOperators.multiplyMatrixProd(SimpleOperators.getPlueckerMatrixDual(B), A);
  }
Exemplo n.º 2
0
  /**
   * Constructs the triangle corresponding to the i-th face in a mesh given the connectivity
   * information fcs and the vertices vtc and adds it to the CompoundShape.
   *
   * @param vtc The vertices of the mesh.
   * @param fcs The faces of the mesh, i.e connectivity information.
   * @param i The index of the face to be constructed.
   */
  private void addTriangleAtIndex(CompoundShape cs, SimpleMatrix vtc, SimpleMatrix fcs, int i) {
    SimpleVector face = fcs.getRow(i);

    SimpleVector dirU = vtc.getRow((int) face.getElement(1));
    dirU.subtract(vtc.getRow((int) face.getElement(0)));
    double l2 = dirU.normL2();
    SimpleVector dirV = vtc.getRow((int) face.getElement(2));
    dirV.subtract(vtc.getRow((int) face.getElement(0)));
    if (dirV.normL2() < l2) {
      l2 = dirV.normL2();
    }
    double nN = General.crossProduct(dirU.normalizedL2(), dirV.normalizedL2()).normL2();

    if (l2 < Math.sqrt(CONRAD.DOUBLE_EPSILON) || nN < Math.sqrt(CONRAD.DOUBLE_EPSILON)) {
    } else {
      Triangle t =
          new Triangle(
              new PointND(vtc.getRow((int) face.getElement(0))),
              new PointND(vtc.getRow((int) face.getElement(1))),
              new PointND(vtc.getRow((int) face.getElement(2))));
      cs.add(t);
    }
  }
Exemplo n.º 3
0
  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);
  }