Package worldBuilder

Class MeshPoint


  • public class MeshPoint
    extends java.lang.Object
    a MeshPoint has X and Y coordinates, and index, and neighbors
    • Field Summary

      Fields 
      Modifier and Type Field Description
      boolean immutable
      corresponds to main-map point and cannot be changed
      int index
      index (in Mesh array) of this MeshPoint
      MeshPoint[] neighbor
      array of neighboring MeshPoints
      int neighbors
      number of neighboring MeshPoints
      double x
      Map coordinates of this point
      double y
      Map coordinates of this point
    • Constructor Summary

      Constructors 
      Constructor Description
      MeshPoint​(double x, double y)
      instantiate a MeshPoint w/no index
      MeshPoint​(double x, double y, int index)
      instantiate a MeshPoint w/known index
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addNeighbor​(MeshPoint p)
      note that we have a neighbor
      double distance​(MeshPoint other)
      compute the (positive) distance between two points
      double distanceLine​(double x1, double y1, double x2, double y2)
      compute the distance to a specified line Notes: - this algorithm computes the area of the triangle (between the line points and point in question), and divides it by the base (between the line points).
      boolean isNeighbor​(MeshPoint point)
      is a particular MeshPoint one of my neighbors
      static void quickSort​(MeshPoint[] arr, int left, int right)
      (recursive) QuickSort an array of MapPoints
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • x

        public double x
        Map coordinates of this point
      • y

        public double y
        Map coordinates of this point
      • index

        public int index
        index (in Mesh array) of this MeshPoint
      • neighbors

        public int neighbors
        number of neighboring MeshPoints
      • neighbor

        public MeshPoint[] neighbor
        array of neighboring MeshPoints
      • immutable

        public boolean immutable
        corresponds to main-map point and cannot be changed
    • Constructor Detail

      • MeshPoint

        public MeshPoint​(double x,
                         double y)
        instantiate a MeshPoint w/no index
        Parameters:
        x - position (-0.5 to 0.5 map coordinate)
        y - position (-0.5 to 0.5 map coordinate)
      • MeshPoint

        public MeshPoint​(double x,
                         double y,
                         int index)
        instantiate a MeshPoint w/known index
        Parameters:
        x - position (-0.5 to 0.5 map coordinate)
        y - position (-0.5 to 0.5 map coordinate)
        index - (in Mesh) of this point
    • Method Detail

      • addNeighbor

        public void addNeighbor​(MeshPoint p)
        note that we have a neighbor
        Parameters:
        p - ... address of new neighbor
      • isNeighbor

        public boolean isNeighbor​(MeshPoint point)
        is a particular MeshPoint one of my neighbors
        Parameters:
        point - MeshPoint to be checked
        Returns:
        true if it is one of my neighbors
      • distance

        public double distance​(MeshPoint other)
        compute the (positive) distance between two points
        Parameters:
        other -
        Returns:
        distance
      • distanceLine

        public double distanceLine​(double x1,
                                   double y1,
                                   double x2,
                                   double y2)
        compute the distance to a specified line Notes: - this algorithm computes the area of the triangle (between the line points and point in question), and divides it by the base (between the line points). - even though end-points are given, this algorithm treates the base-line as infinite, so off the end can still be very close.
        Parameters:
        x1 - map position (-0.5 to 0.5) of one end of line
        y1 - map position (-0.5 to 0.5) of one end of line
        x2 - map position (-0.5 to 0.5) of other end of line
        y2 - map position (-0.5 to 0.5) of other end of line
        Returns:
        distance (which can be positive or negative)
      • quickSort

        public static void quickSort​(MeshPoint[] arr,
                                     int left,
                                     int right)
        (recursive) QuickSort an array of MapPoints
        Parameters:
        arr - ... array to be sorted
        left - ... left most index of sort region
        right - ... right most index of sort region
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        Returns:
        (string) coordinates of point