Class Region


  • @Immutable
    public class Region
    extends java.lang.Object
    Represent a region in space for the RPS system.

    The region is specified by a right-handed set of points.

    Regions are immutable once created.

    This initial implementation of a Region is inherently 2-dimensional, deferring use of the 3rd (Z) dimension to a later implementation. It uses a Java2D GeneralPath to handle the inside/outside calculations.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      (package private) java.awt.geom.GeneralPath path  
      (package private) javax.vecmath.Point3d[] points  
    • Constructor Summary

      Constructors 
      Constructor Description
      Region​(java.lang.String s)
      Ctor from a string like "(0,0,0);(1,0,0);(1,1,0);(0,1,0)" .
      Region​(javax.vecmath.Point3d[] points)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object ro)  
      java.awt.Shape getPath()
      Provide Java2D access to the shape of this region.
      int hashCode()  
      (package private) void initPath​(javax.vecmath.Point3d[] points)  
      boolean isInside​(javax.vecmath.Point3d p)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • path

        java.awt.geom.GeneralPath path
      • points

        final javax.vecmath.Point3d[] points
    • Constructor Detail

      • Region

        public Region​(javax.vecmath.Point3d[] points)
      • Region

        public Region​(java.lang.String s)
        Ctor from a string like "(0,0,0);(1,0,0);(1,1,0);(0,1,0)" .
        Parameters:
        s - construction string.
    • Method Detail

      • getPath

        public java.awt.Shape getPath()
        Provide Java2D access to the shape of this region.

        This should provide a copy of the GeneralPath path, to keep the underlying object immutable, but by returning a Shape type hopefully we achieve the same result with a little better performance. Please don't assume you can cast and modify this.

        Returns:
        the path.
      • initPath

        void initPath​(javax.vecmath.Point3d[] points)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • isInside

        public boolean isInside​(javax.vecmath.Point3d p)
      • equals

        public boolean equals​(java.lang.Object ro)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object