Package pointgon

Class Pointgon

java.lang.Object
pointgon.Pointgon
All Implemented Interfaces:
Serializable

public class Pointgon extends Object implements Serializable
Class for pointgons (polygons with holes that are points).
Since:
2005.02.18 (Christian Borgelt)
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    edges of partition
    vector of hole vertices
    vector of perimeter vertices
  • Constructor Summary

    Constructors
    Constructor
    Description
    Pointgon(int vertcnt, int holecnt)
    Create a pointgon.
    Pointgon(int vertcnt, int holecnt, double radius, Random rand)
    Create a random pointgon.
    Read a pointgon from an input stream.
    Read a pointgon from a string description.
    Pointgon(util.Scanner s)
    Read a pointgon from a scanner.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addEdge(Edge edge)
    Add an inner edge to the pointgon (triangulation).
    void
    addHole(double x, double y)
    Add a hole vertex to a pointgon.
    void
    addVertex(double x, double y)
    Add a perimeter vertex to a pointgon.
    boolean
    Check whether all holes are inside the pointgon.
    boolean
    Check for duplicate holes.
    findEdge(double x, double y)
    Find the closest edge to a given point.
    findVertex(double x, double y)
    Find the closest vertex to a given point.
    double
    Get the height of the bounding box.
    double
    Get the width the bounding box.
    double
    Get the x-coordinate of lower left corner of the bounding box.
    double
    Get the y-coordinate of lower left corner of the bounding box.
    boolean
    Check whether the pointgon is convex.
    boolean
    Check for perimieter intersections.
    boolean
    Check whether a vertex is inside the pointgon.
    boolean
    Check for a valid state of the pointgon.
    static void
    main(String[] args)
    Main program for command line invocation.
    void
    Remove an inner edge from the pointgon (triangulation).
    void
    resize(int vertcnt, int holecnt)
    Resize a pointgon (change number of vertices).
    void
    Reverse (the order of) the perimeter vertices.
    void
    setEdges(Edge[] edges)
    Set the inner edges of the pointgon (triangulation).
    Create a string description of the pointgon.
    void
    transform(double scale, double xoff, double yoff)
    Scale and shift a pointgon.
    double
    weight(boolean withPerimeter)
    Compute the total weight of the edges.

    Methods inherited from class java.lang.Object

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

    • verts

      public Vertex[] verts
      vector of perimeter vertices
    • holes

      public Vertex[] holes
      vector of hole vertices
    • edges

      public Edge[] edges
      edges of partition
  • Constructor Details

    • Pointgon

      public Pointgon(int vertcnt, int holecnt)
      Create a pointgon.
      Parameters:
      vertcnt - the number of perimeter vertices
      holecnt - the number of holes
      Since:
      2005.02.18 (Christian Borgelt)
    • Pointgon

      public Pointgon(int vertcnt, int holecnt, double radius, Random rand)
      Create a random pointgon.
      Parameters:
      vertcnt - the number of perimeter vertices
      holecnt - the number of holes
      radius - the radius parameter (maximum perimeter vertex distance from origin)
      rand - the random number generator
      Since:
      2005.02.18 (Christian Borgelt)
    • Pointgon

      public Pointgon(util.Scanner s) throws IOException
      Read a pointgon from a scanner.
      Parameters:
      s - the scanner to read from
      Throws:
      IOException - if a read error occcurred
      Since:
      2005.02.18 (Christian Borgelt)
    • Pointgon

      public Pointgon(String desc) throws IOException
      Read a pointgon from a string description.
      Parameters:
      desc - the string description to read from
      Throws:
      IOException - if a read error occcurred
      Since:
      2005.02.18 (Christian Borgelt)
    • Pointgon

      public Pointgon(InputStream in) throws IOException
      Read a pointgon from an input stream.
      Parameters:
      in - the input stream to read from
      Throws:
      IOException - if a read error occcurred
      Since:
      2005.02.18 (Christian Borgelt)
  • Method Details

    • addVertex

      public void addVertex(double x, double y)
      Add a perimeter vertex to a pointgon.
      Parameters:
      x - the x-coordinate of the vertex
      y - the y-coordinate of the vertex
      Since:
      2005.02.18 (Christian Borgelt)
    • addHole

      public void addHole(double x, double y)
      Add a hole vertex to a pointgon.
      Parameters:
      x - the x-coordinate of the hole vertex
      y - the y-coordinate of the hole vertex
      Since:
      2005.02.18 (Christian Borgelt)
    • setEdges

      public void setEdges(Edge[] edges)
      Set the inner edges of the pointgon (triangulation).
      Parameters:
      edges - the array of edges to set
      Since:
      2005.02.18 (Christian Borgelt)
    • addEdge

      public boolean addEdge(Edge edge)
      Add an inner edge to the pointgon (triangulation).
      Parameters:
      edge - the edge to add
      Returns:
      whether the edge was added
      Since:
      2005.02.18 (Christian Borgelt)
    • removeEdge

      public void removeEdge(Edge edge)
      Remove an inner edge from the pointgon (triangulation).
      Parameters:
      edge - the edge to remove
      Since:
      2005.02.18 (Christian Borgelt)
    • resize

      public void resize(int vertcnt, int holecnt)
      Resize a pointgon (change number of vertices).
      Parameters:
      vertcnt - the new number of perimeter vertices
      holecnt - the new number of holes
      Since:
      2005.02.18 (Christian Borgelt)
    • transform

      public void transform(double scale, double xoff, double yoff)
      Scale and shift a pointgon.
      Parameters:
      scale - the scaling parameter
      xoff - the x-offset by which to shift
      yoff - the y-offset by which to shift
      Since:
      2005.02.18 (Christian Borgelt)
    • getX

      public double getX()
      Get the x-coordinate of lower left corner of the bounding box.
      Returns:
      the x-coordinate of lower left corner of the bounding box
      Since:
      2005.02.18 (Christian Borgelt)
    • getY

      public double getY()
      Get the y-coordinate of lower left corner of the bounding box.
      Returns:
      the y-coordinate of lower left corner of the bounding box
      Since:
      2005.02.18 (Christian Borgelt)
    • getWidth

      public double getWidth()
      Get the width the bounding box.
      Returns:
      the width of the bounding box
      Since:
      2005.02.18 (Christian Borgelt)
    • getHeight

      public double getHeight()
      Get the height of the bounding box.
      Returns:
      the height of the bounding box
      Since:
      2005.02.18 (Christian Borgelt)
    • reverse

      public void reverse()
      Reverse (the order of) the perimeter vertices.
      Since:
      2005.02.18 (Christian Borgelt)
    • isConvex

      public boolean isConvex()
      Check whether the pointgon is convex.
      Returns:
      whether the pointgon is convex
      Since:
      2005.02.18 (Christian Borgelt)
    • isInside

      public boolean isInside(Vertex v)
      Check whether a vertex is inside the pointgon.
      Parameters:
      v - the vertex to check
      Returns:
      whether the vertex is inside the pointgon
      Since:
      2005.02.18 (Christian Borgelt)
    • allHolesInside

      public boolean allHolesInside()
      Check whether all holes are inside the pointgon.
      Returns:
      whether all holes are inside the pointgon
      Since:
      2005.02.18 (Christian Borgelt)
    • duplicates

      public boolean duplicates()
      Check for duplicate holes.
      Returns:
      whether there are duplicate holes
      Since:
      2005.02.18 (Christian Borgelt)
    • isects

      public boolean isects()
      Check for perimieter intersections.
      Returns:
      whether there are perimeter intersections
      Since:
      2005.02.18 (Christian Borgelt)
    • isValid

      public boolean isValid()
      Check for a valid state of the pointgon.

      A pointgon is valid if there are no duplicate holes, all holes are inside the pointgon and there are no perimeter intersections.

      Returns:
      whether there are perimeter intersections
      Since:
      2005.02.18 (Christian Borgelt)
    • weight

      public double weight(boolean withPerimeter)
      Compute the total weight of the edges.
      Parameters:
      withPerimeter - whether to include the perimeter edges
      Returns:
      the total weight of the edges
      Since:
      2005.02.18 (Christian Borgelt)
    • findVertex

      public Vertex findVertex(double x, double y)
      Find the closest vertex to a given point.
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      Returns:
      the closest vertex to the point
      Since:
      2005.02.18 (Christian Borgelt)
    • findEdge

      public Edge findEdge(double x, double y)
      Find the closest edge to a given point.
      Parameters:
      x - the x-coordinate of the point
      y - the y-coordinate of the point
      Returns:
      the closest edge to the point
      Since:
      2005.02.18 (Christian Borgelt)
    • toString

      public String toString()
      Create a string description of the pointgon.
      Overrides:
      toString in class Object
      Returns:
      the created string description
      Since:
      2005.02.18 (Christian Borgelt)
    • main

      public static void main(String[] args)
      Main program for command line invocation.
      Parameters:
      args - the command line arguments
      Since:
      2005.02.18 (Christian Borgelt)