Ejemplo 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);
  }
Ejemplo 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);
    }
  }