Class Quadrilateral

java.lang.Object
org.sm.smtools.math.quadmapping.Quadrilateral

public final class Quadrilateral
extends java.lang.Object
The 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:
Quadrilateral, QuadMapping, QuadToQuadMapping
  • Field Summary

    Fields
    Modifier and Type Field Description
    java.awt.geom.Point2D.Double fP1
    The quadrilateral's first point.
    java.awt.geom.Point2D.Double fP2
    The quadrilateral's second point.
    java.awt.geom.Point2D.Double fP3
    The quadrilateral's third point.
    java.awt.geom.Point2D.Double fP4
    The quadrilateral's fourth point.
  • Constructor Summary

    Constructors
    Constructor Description
    Quadrilateral()
    Constructs a Quadrilateral object with all four 2D points equal to (0,0).
    Quadrilateral​(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, java.awt.geom.Point2D.Double p3, java.awt.geom.Point2D.Double p4)
    Constructs a Quadrilateral object with the four specified 2D points.
    Quadrilateral​(Quadrilateral q)
    Constructs a Quadrilateral object as a copy of another Quadrilateral object.
  • Method Summary

    Modifier and Type Method Description
    void clear()
    Sets all four 2D-points of this Quadrilateral object equal to (0,0).
    boolean isConvex()
    Returns whether or not this Quadrilateral object is convex shaped.
    boolean isScreenConvex()
    Returns whether or not this Quadrilateral object is convex shaped on the screen.
    void permuteCounterClockwise()
    Permutes all four 2D points of this Quadrilateral object counter clockwise.
    void permuteVertical()
    Permutes all four 2D points of this Quadrilateral object vertically.
    void set​(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, java.awt.geom.Point2D.Double p3, java.awt.geom.Point2D.Double p4)
    Sets all four 2D points of this Quadrilateral object equal to the specified points.
    void set​(Quadrilateral q)
    Sets all four 2D points of this Quadrilateral object equal to those of the specified Quadrilateral object.

    Methods inherited from class java.lang.Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fP1

      public java.awt.geom.Point2D.Double fP1
      The quadrilateral's first point.
    • fP2

      public java.awt.geom.Point2D.Double fP2
      The quadrilateral's second point.
    • fP3

      public java.awt.geom.Point2D.Double fP3
      The quadrilateral's third point.
    • fP4

      public java.awt.geom.Point2D.Double fP4
      The quadrilateral's fourth point.
  • Constructor Details

  • Method Details

    • clear

      public void clear()
      Sets all four 2D-points of this Quadrilateral object equal to (0,0).
    • set

      public void set​(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, java.awt.geom.Point2D.Double p3, java.awt.geom.Point2D.Double p4)
      Sets all four 2D points of this Quadrilateral 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(Quadrilateral)
    • set

      public void set​(Quadrilateral q)
      Sets all four 2D points of this Quadrilateral object equal to those of the specified Quadrilateral 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:
      set(Point2D.Double,Point2D.Double,Point2D.Double,Point2D.Double)
    • permuteCounterClockwise

      public void permuteCounterClockwise()
      Permutes all four 2D points of this Quadrilateral object counter clockwise.

      After the operation, the 2D points have changed as follows:

      • fP1 → fP2
      • fP2 → fP3
      • fP3 → fP4
      • fP4 → fP1
      See Also:
      permuteVertical()
    • permuteVertical

      public void permuteVertical()
      Permutes all four 2D points of this Quadrilateral 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:
      permuteCounterClockwise()
    • isConvex

      public boolean isConvex()
      Returns whether or not this Quadrilateral 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 this Quadrilateral object is convex shaped, false otherwise
      See Also:
      isScreenConvex()
    • isScreenConvex

      public boolean isScreenConvex()
      Returns whether or not this Quadrilateral 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 this Quadrilateral object is convex shaped on the screen, false otherwise
      See Also:
      isConvex()