boolean areMiddlePointsClose ( Point2D_F64 p0 , Point2D_F64 p1 , Point2D_F64 p2 , Point2D_F64 p3 ) { UtilLine2D_F64 . convert ( p0 , p3 , line ) ; // (computed expected length of a square) * (fractional tolerance) double tol1 = p0 . distance ( p1 ) * distanceTol ; // see if inner points are close to the line if ( Distance2D_F64 . distance ( line , p1 ) > tol1 ) return false ; double tol2 = p2 . distance ( p3 ) * distanceTol ; if ( Distance2D_F64 . distance ( lineB , p2 ) > tol2 ) return false ; //------------ Now see if the line defined by one side of a square is close to the closest point on the same // side on the other square UtilLine2D_F64 . convert ( p0 , p1 , line ) ; if ( Distance2D_F64 . distance ( line , p2 ) > tol2 ) return false ; UtilLine2D_F64 . convert ( p3 , p2 , line ) ; if ( Distance2D_F64 . distance ( line , p1 ) > tol1 ) return false ; return true ; }
Returns true if point p1 and p2 are close to the line defined by points p0 and p3 .