Package worldBuilder
Class MeshPoint
- java.lang.Object
 - 
- worldBuilder.MeshPoint
 
 
- 
public class MeshPoint extends java.lang.Objecta MeshPoint has X and Y coordinates, and index, and neighbors 
- 
- 
Field Summary
Fields Modifier and Type Field Description booleanimmutablecorresponds to main-map point and cannot be changedintindexindex (in Mesh array) of this MeshPointMeshPoint[]neighborarray of neighboring MeshPointsintneighborsnumber of neighboring MeshPointsdoublexMap coordinates of this pointdoubleyMap coordinates of this point 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddNeighbor(MeshPoint p)note that we have a neighbordoubledistance(MeshPoint other)compute the (positive) distance between two pointsdoubledistanceLine(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).booleanisNeighbor(MeshPoint point)is a particular MeshPoint one of my neighborsstatic voidquickSort(MeshPoint[] arr, int left, int right)(recursive) QuickSort an array of MapPointsjava.lang.StringtoString() 
 - 
 
- 
- 
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 liney1- map position (-0.5 to 0.5) of one end of linex2- map position (-0.5 to 0.5) of other end of liney2- 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 sortedleft- ... left most index of sort regionright- ... right most index of sort region
 
- 
toString
public java.lang.String toString()
- Overrides:
 toStringin classjava.lang.Object- Returns:
 - (string) coordinates of point
 
 
 - 
 
 -