Class Quadrilateral
Quadrilateral
class provides a container for a 2D quadrilateral.
Note that a counter clockwise specified quadrilateral is preferred:
Note that this class cannot be subclassed!
- Version:
- 09/12/2004
- Author:
- Sven Maerivoet
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe quadrilateral's first point.The quadrilateral's second point.The quadrilateral's third point.The quadrilateral's fourth point. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs aQuadrilateral
object with all four 2D points equal to (0,0).Quadrilateral
(Point2D.Double p1, Point2D.Double p2, Point2D.Double p3, Point2D.Double p4) Constructs aQuadrilateral
object with the four specified 2D points.Constructs aQuadrilateral
object as a copy of anotherQuadrilateral
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Sets all four 2D-points of thisQuadrilateral
object equal to (0,0).boolean
isConvex()
Returns whether or not thisQuadrilateral
object is convex shaped.boolean
Returns whether or not thisQuadrilateral
object is convex shaped on the screen.void
Permutes all four 2D points of thisQuadrilateral
object counter clockwise.void
Permutes all four 2D points of thisQuadrilateral
object vertically.void
set
(Point2D.Double p1, Point2D.Double p2, Point2D.Double p3, Point2D.Double p4) Sets all four 2D points of thisQuadrilateral
object equal to the specified points.void
set
(Quadrilateral q) Sets all four 2D points of thisQuadrilateral
object equal to those of the specifiedQuadrilateral
object.
-
Field Details
-
fP1
The quadrilateral's first point. -
fP2
The quadrilateral's second point. -
fP3
The quadrilateral's third point. -
fP4
The quadrilateral's fourth point.
-
-
Constructor Details
-
Quadrilateral
public Quadrilateral()Constructs aQuadrilateral
object with all four 2D points equal to (0,0). -
Quadrilateral
Constructs aQuadrilateral
object with the four specified 2D points.Note that internally, the four specified points are referenced; this means that any changes to the specified points are reflected in the internal
Point2D.Double
objects.- Parameters:
p1
- the quadrilateral's first point (shallow copy)p2
- the quadrilateral's second point (shallow copy)p3
- the quadrilateral's third point (shallow copy)p4
- the quadrilateral's fourth point (shallow copy)- See Also:
-
Quadrilateral
Constructs aQuadrilateral
object as a copy of anotherQuadrilateral
object.This is the copy constructor.
Note that internally, the four specified points are referenced; this means that any changes to the specified points are reflected in the internal
Point2D.Double
objects.- Parameters:
q
- the quadrilateral's 2D-datapoints to shallow copy- See Also:
-
-
Method Details
-
clear
public void clear()Sets all four 2D-points of thisQuadrilateral
object equal to (0,0). -
set
Sets all four 2D points of thisQuadrilateral
object equal to the specified points.Note that internally, the four specified points are referenced; this means that any changes to the specified points are reflected in the internal
Point2D
objects.- Parameters:
p1
- the quadrilateral's first point (shallow copy)p2
- the quadrilateral's second point (shallow copy)p3
- the quadrilateral's third point (shallow copy)p4
- the quadrilateral's fourth point (shallow copy)- See Also:
-
set
Sets all four 2D points of thisQuadrilateral
object equal to those of the specifiedQuadrilateral
object.Note that internally, the four specified points are referenced; this means that any changes to the specified points are reflected in the internal
Point2D.Double
objects.- Parameters:
q
- the quadrilateral's 2D-data points to shallow copy- See Also:
-
permuteCounterClockwise
public void permuteCounterClockwise()Permutes all four 2D points of thisQuadrilateral
object counter clockwise.After the operation, the 2D points have changed as follows:
- fP1 → fP2
- fP2 → fP3
- fP3 → fP4
- fP4 → fP1
- See Also:
-
permuteVertical
public void permuteVertical()Permutes all four 2D points of thisQuadrilateral
object vertically.After the operation, the 2D points have changed as follows:
- fP1 → fP3
- fP2 → fP4
- fP3 → fP1
- fP4 → fP2
This corresponds to two consecutive counter clockwise permutations.
- See Also:
-
isConvex
public boolean isConvex()Returns whether or not thisQuadrilateral
object is convex shaped.Note: it is assumed that the X axis points to the right and the Y axis points upwards.
- Returns:
true
if thisQuadrilateral
object is convex shaped,false
otherwise- See Also:
-
isScreenConvex
public boolean isScreenConvex()Returns whether or not thisQuadrilateral
object is convex shaped on the screen.Note: it is assumed that the X axis points to the right and the Y axis points downwards.
- Returns:
true
if thisQuadrilateral
object is convex shaped on the screen,false
otherwise- See Also:
-