public class PointInSquare extends PointMatcher
point| Constructor and Description |
|---|
PointInSquare(Point2D p,
double halfLength)
Creates an object that matches all points strictly within a square
neighbourhood surrounding the point
p. |
| Modifier and Type | Method and Description |
|---|---|
double |
getHalfLength()
Returns the size of the square neighbourhood used for matching.
|
boolean |
matches(Point2D other)
Checks if the point
other is strictly inside the square
neighbourhood surrounding the point held by this matcher. |
getPoint, setPointpublic PointInSquare(Point2D p, double halfLength)
p. The size of the square
is determined by the parameter halfLength which is one half of
the length of the side of the square (see figure below).
p - the point at the center of the square neighbourhoodhalfLength - half the length of the side of the squarepublic double getHalfLength()
public boolean matches(Point2D other)
other is strictly inside the square
neighbourhood surrounding the point held by this matcher. If
other has coordinates (x, y), and the point held by
this matcher has coordinates (px, py), and the half length of
the square neighbourhood is h, then the result is
true if and only if:
| px - x | < h is true
AND
| py - y | < h is true
matches in class PointMatcherPointMatcher.matches(cse1030.drawing.Point2D)other - the point to check for a matchtrue if other is strictly inside the
square neighbourhood surround the point held by this matcher