Since the sign of the homography is ambiguous a point is required to make sure the correct
one was selected.

@param p test point, used to determine the sign of the matrix.
977217
protected void adjustHomographSign( PairLineNorm p , DMatrixRMaj H ) {

		CommonOps_DDRM.transpose(H,H_t);

		double val = GeometryMath_F64.innerProd(p.l1, H_t, p.l2);

		if( val < 0 )
			CommonOps_DDRM.scale(-1, H);
	}
118936
function(p) {

        var start = this.start;
        var end = this.end;

        if (start.cross(p, end) !== 0) return false;
        // else: cross product of 0 indicates that this line and the vector to `p` are collinear

        var length = this.length();
        if ((new g.Line(start, p)).length() > length) return false;
        if ((new g.Line(p, end)).length() > length) return false;
        // else: `p` lies between start and end of the line

        return true;
    }
180495
@Pure
	public boolean containsProjectionOf(Point3f point) {
		return containsProjectionOf(point.getX(), point.getY(), point.getZ());
	}
903306
function(p) {

            if (!p) return false;

            var points = this.points;
            var otherPoints = p.points;

            var numPoints = points.length;
            if (otherPoints.length !== numPoints) return false; // if the two polylines have different number of points, they cannot be equal

            for (var i = 0; i < numPoints; i++) {

                var point = points[i];
                var otherPoint = p.points[i];

                // as soon as an inequality is found in points, return false
                if (!point.equals(otherPoint)) return false;
            }

            // if no inequality found in points, return true
            return true;
        }
476507
public boolean isMultiPoint() {
    boolean mp = true;
    if (this == UNDEFINED) { mp = false; }
    else if (this == NULL) { mp = false; }
    else if (this == POINT) { mp = false; }
    return mp;
  }
819056
def pointIsInTriangle(p, p1, p2, p3):
    
    p = np.array(p)
    u = np.array(p2) - p1
    v = np.array(p3) - p1
    n = np.cross(u, v)
    w = p - p1
    ln = np.dot(n, n)
    if not ln:
        return True  # degenerate triangle
    gamma = (np.dot(np.cross(u, w), n)) / ln
    beta = (np.dot(np.cross(w, v), n)) / ln
    alpha = 1 - gamma - beta
    if 0 < alpha < 1 and 0 < beta < 1 and 0 < gamma < 1:
        return True
    return False
647153
public void setPos(Object p) {
        Object[] a = (Object[]) p;
        buf = (char[]) a[0];
        int[] v = (int[]) a[1];
        pos.setIndex(v[0]);
        bufPos = v[1];
    }
1103685
public final void set(Point p1, Point p2)
    {
        set(p1.getX(), p1.getY(), p2.getX(), p2.getY());
    }
1188016
public void check_in(double[] p) {
        if (p != null) {
            L.add(p);
        } else {
            System.out.println("Miniball.check_in WARNING: Skipping null point");
        }
    }
1201554
public double dot(Point p)
	{
		return (x * p.x) + (y * p.y) + (z * p.z);
	}
165588
private static boolean pointEqualsPoint_(Point2D pt_a, Point2D pt_b,
			double tolerance, ProgressTracker progress_tracker) {
		if (Point2D.sqrDistance(pt_a, pt_b) <= tolerance * tolerance)
			return true;

		return false;
	}
892893
@Override
	public void set(Point3D p1, Point3D p2, Point3D p3) {
		set(p1.getX(), p1.getY(), p1.getZ(), p2.getX(), p2.getY(), p2.getZ(), p3.getX(), p3.getY(), p3.getZ());
	}
278906
public void markConstrainedEdge( TriangulationPoint p, TriangulationPoint q )
    {
        if( ( q == points[0] && p == points[1] ) || ( q == points[1] && p == points[0] ) )
        {
            cEdge[2] = true;
        }
        else if( ( q == points[0] && p == points[2] ) || ( q == points[2] && p == points[0] ) )
        {
            cEdge[1] = true;
        }
        else if( ( q == points[1] && p == points[2] ) || ( q == points[2] && p == points[1] ) )
        {
            cEdge[0] = true;
        }
    }
575094
function isSamePoint(pointA, pointB) {
  return pointA.node === pointB.node && pointA.offset === pointB.offset;
}
1203853
private ResultPoint[] detectSolid1(ResultPoint[] cornerPoints) {
    // 0  2
    // 1  3
    ResultPoint pointA = cornerPoints[0];
    ResultPoint pointB = cornerPoints[1];
    ResultPoint pointC = cornerPoints[3];
    ResultPoint pointD = cornerPoints[2];

    int trAB = transitionsBetween(pointA, pointB);
    int trBC = transitionsBetween(pointB, pointC);
    int trCD = transitionsBetween(pointC, pointD);
    int trDA = transitionsBetween(pointD, pointA);

    // 0..3
    // :  :
    // 1--2
    int min = trAB;
    ResultPoint[] points = {pointD, pointA, pointB, pointC};
    if (min > trBC) {
      min = trBC;
      points[0] = pointA;
      points[1] = pointB;
      points[2] = pointC;
      points[3] = pointD;
    }
    if (min > trCD) {
      min = trCD;
      points[0] = pointB;
      points[1] = pointC;
      points[2] = pointD;
      points[3] = pointA;
    }
    if (min > trDA) {
      points[0] = pointC;
      points[1] = pointD;
      points[2] = pointA;
      points[3] = pointB;
    }

    return points;
  }
1278100
static boolean multiPointRelatePoint_(MultiPoint multipoint_a,
			Point point_b, double tolerance, String scl,
			ProgressTracker progress_tracker) {
		RelationalOperationsMatrix relOps = new RelationalOperationsMatrix();
		relOps.resetMatrix_();
		relOps.setPredicates_(scl);
		relOps.setPointPointPredicates_();

		Envelope2D env_a = new Envelope2D();
		multipoint_a.queryEnvelope2D(env_a);
		Point2D pt_b = point_b.getXY();

		boolean bRelationKnown = false;
		boolean b_disjoint = RelationalOperations.pointDisjointEnvelope_(pt_b,
				env_a, tolerance, progress_tracker);

		if (b_disjoint) {
			relOps.pointPointDisjointPredicates_();
			bRelationKnown = true;
		}

		if (!bRelationKnown) {
			boolean b_intersects = false;
			boolean b_multipoint_contained = true;
			double tolerance_sq = tolerance * tolerance;

			for (int i = 0; i < multipoint_a.getPointCount(); i++) {
				Point2D pt_a = multipoint_a.getXY(i);

				if (Point2D.sqrDistance(pt_a, pt_b) <= tolerance_sq)
					b_intersects = true;
				else
					b_multipoint_contained = false;

				if (b_intersects && !b_multipoint_contained)
					break;
			}

			if (b_intersects) {
				relOps.m_matrix[MatrixPredicate.InteriorInterior] = 0;

				if (!b_multipoint_contained)
					relOps.m_matrix[MatrixPredicate.InteriorExterior] = 0;
				else
					relOps.m_matrix[MatrixPredicate.InteriorExterior] = -1;

				relOps.m_matrix[MatrixPredicate.ExteriorInterior] = -1;
			} else {
				relOps.m_matrix[MatrixPredicate.InteriorInterior] = -1;
				relOps.m_matrix[MatrixPredicate.InteriorExterior] = 0;
				relOps.m_matrix[MatrixPredicate.ExteriorInterior] = 0;
			}
		}

		boolean bRelation = relationCompare_(relOps.m_matrix, scl);
		return bRelation;
	}
1313994
boolean computeRectifyH( double f1 , double f2 , DMatrixRMaj P2, DMatrixRMaj H ) {

		estimatePlaneInf.setCamera1(f1,f1,0,0,0);
		estimatePlaneInf.setCamera2(f2,f2,0,0,0);

		if( !estimatePlaneInf.estimatePlaneAtInfinity(P2,planeInf) )
			return false;

		// TODO add a cost for distance from nominal and scale other cost by focal length fx for each view
//		RefineDualQuadraticConstraint refine = new RefineDualQuadraticConstraint();
//		refine.setZeroSkew(true);
//		refine.setAspectRatio(true);
//		refine.setZeroPrinciplePoint(true);
//		refine.setKnownIntrinsic1(true);
//		refine.setFixedCamera(false);
//
//		CameraPinhole intrinsic = new CameraPinhole(f1,f1,0,0,0,0,0);
//		if( !refine.refine(normalizedP.toList(),intrinsic,planeInf))
//			return false;

		K1.zero();
		K1.set(0,0,f1);
		K1.set(1,1,f1);
		K1.set(2,2,1);
		MultiViewOps.createProjectiveToMetric(K1,planeInf.x,planeInf.y,planeInf.z,1,H);

		return true;
	}