uk.ac.leeds.ccg.andyt.vector.geometry
Class Vector_Point2D

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.vector.geometry.Vector_AbstractGeometry2D
      extended by uk.ac.leeds.ccg.andyt.vector.geometry.Vector_Point2D
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable

public class Vector_Point2D
extends Vector_AbstractGeometry2D
implements java.lang.Comparable, java.io.Serializable

Class for points in 2D.

See Also:
Serialized Form

Field Summary
 java.math.BigDecimal _x
          The x coordinate of the Vector_Point2D
 java.math.BigDecimal _y
          The y coordinate of the Vector_Point2D
 
Fields inherited from class uk.ac.leeds.ccg.andyt.vector.geometry.Vector_AbstractGeometry2D
_DecimalPlacePrecision_Integer, _RoundingMode, _Vector_Environment
 
Constructor Summary
Vector_Point2D()
          Creates a default Vector_Point2D with: _x = null; _y = null;
Vector_Point2D(java.math.BigDecimal _x, java.math.BigDecimal _y)
          this._x = new BigDecimal(_x.toString()); this._y = new BigDecimal(_y.toString()); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));
Vector_Point2D(java.math.BigDecimal _x, java.math.BigDecimal _y, java.math.BigDecimal toRoundToX_BigDecimal, java.math.BigDecimal toRoundToY_BigDecimal)
          this._x = VectorStaticBigDecimal.getRounded_BigDecimal( _x, toRoundToX_BigDecimal); this._y = VectorStaticBigDecimal.getRounded_BigDecimal( _y, toRoundToY_BigDecimal); set_DecimalPlacePrecision(toRoundTo_BigDecimal.scale());
Vector_Point2D(java.math.BigDecimal _x, java.math.BigDecimal _y, int _DecimalPlacePrecision)
          this._x = new BigDecimal(_x.toString()); this._y = new BigDecimal(_y.toString()); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);
Vector_Point2D(double x, double y)
          Deprecated.  
Vector_Point2D(double x, double y, java.math.BigDecimal toRoundToX_BigDecimal, java.math.BigDecimal toRoundToY_BigDecimal)
          this._x = VectorStaticBigDecimal.getRounded_BigDecimal( new BigDecimal(x), toRoundToX_BigDecimal); this._y = VectorStaticBigDecimal.getRounded_BigDecimal( new BigDecimal(y), toRoundToY_BigDecimal); set_DecimalPlacePrecision( Math.max( toRoundToX_BigDecimal.scale(), toRoundToY_BigDecimal.scale()));
Vector_Point2D(double x, double y, int _DecimalPlacePrecision)
          _x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);
Vector_Point2D(java.lang.String x, java.lang.String y)
          _x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));
Vector_Point2D(java.lang.String x, java.lang.String y, int _DecimalPlacePrecision)
          _x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);
Vector_Point2D(Vector_Point2D a_Point2D)
          _x = new BigDecimal(aPoint2D._x.toString()); _y = new BigDecimal(aPoint2D._y.toString()); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));
Vector_Point2D(Vector_Point2D a_Point2D, java.math.BigDecimal toRoundToX_BigDecimal, java.math.BigDecimal toRoundToY_BigDecimal)
          _x = new BigDecimal(a_Point2D._x.toString()); _y = new BigDecimal(a_Point2D._y.toString()); _x = VectorStaticBigDecimal.getRounded_BigDecimal( _x, toRoundToX_BigDecimal); _y = VectorStaticBigDecimal.getRounded_BigDecimal( _y, toRoundToY_BigDecimal); set_DecimalPlacePrecision( Math.max( toRoundToX_BigDecimal.scale(), toRoundToY_BigDecimal.scale()));
Vector_Point2D(Vector_Point2D a_Point2D, int _DecimalPlacePrecision)
          _x = new BigDecimal(aPoint2D._x.toString()); _y = new BigDecimal(aPoint2D._y.toString()); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);
 
Method Summary
 void applyDecimalPlacePrecision()
           
 int compareTo(java.lang.Object o)
          Default is 1.
 boolean equals(java.lang.Object o)
           
 java.math.BigDecimal getAngle_BigDecimal(Vector_Point2D a_Point2D)
          Imprecise, but uses BigMath and BigFunction default precision
 double getAngle_double(Vector_Point2D a_Point2D)
          Imprecise: Uses Java double precision for all calculations
 java.math.BigDecimal getDistance(Vector_Point2D a_VectorPoint2D, int a_DecimalPlacePrecision)
          Precise to a_DecimalPlacePrecision number of decimal places given precision of a_VectorPoint2D and this.
 Vector_Envelope2D getEnvelope2D()
           
 java.math.BigDecimal getGradient(Vector_Point2D a_Point2D, int a_DecimalPlacePrecision)
           
 boolean getIntersects(Vector_LineSegment2D a_LineSegment2D, int a_DecimalPlacePrecisionForCalculations)
           
 int hashCode()
           
 void roundTo(java.math.BigDecimal toRoundTo_BigDecimal)
           
 int set_DecimalPlacePrecision(int _DecimalPlacePrecision)
          Default method probably best overridden to determine what setting _DecimalPlacePrecision_Integer involves
 double[] to_doubleArray()
          double[] result = new double[2]; result[0] = this._x.doubleValue(); result[1] = this._y.doubleValue(); return result;
 java.lang.String toString()
           
 
Methods inherited from class uk.ac.leeds.ccg.andyt.vector.geometry.Vector_AbstractGeometry2D
get_DecimalPlacePrecision, get_RoundingMode, getDefault_RoundingMode, getDefaultDecimalPlacePrecision_int
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_x

public java.math.BigDecimal _x
The x coordinate of the Vector_Point2D


_y

public java.math.BigDecimal _y
The y coordinate of the Vector_Point2D

Constructor Detail

Vector_Point2D

public Vector_Point2D()
Creates a default Vector_Point2D with: _x = null; _y = null;


Vector_Point2D

public Vector_Point2D(Vector_Point2D a_Point2D)
_x = new BigDecimal(aPoint2D._x.toString()); _y = new BigDecimal(aPoint2D._y.toString()); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));

Parameters:
a_Point2D -

Vector_Point2D

public Vector_Point2D(Vector_Point2D a_Point2D,
                      int _DecimalPlacePrecision)
_x = new BigDecimal(aPoint2D._x.toString()); _y = new BigDecimal(aPoint2D._y.toString()); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);

Parameters:
aPoint2D -
_DecimalPlacePrecision_Integer -

Vector_Point2D

public Vector_Point2D(Vector_Point2D a_Point2D,
                      java.math.BigDecimal toRoundToX_BigDecimal,
                      java.math.BigDecimal toRoundToY_BigDecimal)
_x = new BigDecimal(a_Point2D._x.toString()); _y = new BigDecimal(a_Point2D._y.toString()); _x = VectorStaticBigDecimal.getRounded_BigDecimal( _x, toRoundToX_BigDecimal); _y = VectorStaticBigDecimal.getRounded_BigDecimal( _y, toRoundToY_BigDecimal); set_DecimalPlacePrecision( Math.max( toRoundToX_BigDecimal.scale(), toRoundToY_BigDecimal.scale()));

Parameters:
aPoint2D -
BigDecimal - toRoundToX_BigDecimal
BigDecimal - toRoundToY_BigDecimal

Vector_Point2D

public Vector_Point2D(java.math.BigDecimal _x,
                      java.math.BigDecimal _y)
this._x = new BigDecimal(_x.toString()); this._y = new BigDecimal(_y.toString()); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));

Parameters:
_x -
_y -

Vector_Point2D

public Vector_Point2D(java.math.BigDecimal _x,
                      java.math.BigDecimal _y,
                      int _DecimalPlacePrecision)
this._x = new BigDecimal(_x.toString()); this._y = new BigDecimal(_y.toString()); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);

Parameters:
_x -
_y -
_DecimalPlacePrecision_Integer -

Vector_Point2D

public Vector_Point2D(java.math.BigDecimal _x,
                      java.math.BigDecimal _y,
                      java.math.BigDecimal toRoundToX_BigDecimal,
                      java.math.BigDecimal toRoundToY_BigDecimal)
this._x = VectorStaticBigDecimal.getRounded_BigDecimal( _x, toRoundToX_BigDecimal); this._y = VectorStaticBigDecimal.getRounded_BigDecimal( _y, toRoundToY_BigDecimal); set_DecimalPlacePrecision(toRoundTo_BigDecimal.scale());

Parameters:
_x -
_y -
BigDecimal - toRoundToX_BigDecimal
BigDecimal - toRoundToY_BigDecimal

Vector_Point2D

public Vector_Point2D(java.lang.String x,
                      java.lang.String y)
_x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));

Parameters:
x -
y -

Vector_Point2D

public Vector_Point2D(java.lang.String x,
                      java.lang.String y,
                      int _DecimalPlacePrecision)
_x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);

Parameters:
x -
y -
_DecimalPlacePrecision_Integer -

Vector_Point2D

public Vector_Point2D(double x,
                      double y)
Deprecated. 

_x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(Math.max(_x.scale(),_y.scale()));

Parameters:
x -
y -

Vector_Point2D

public Vector_Point2D(double x,
                      double y,
                      int _DecimalPlacePrecision)
_x = new BigDecimal(x); _y = new BigDecimal(y); set_DecimalPlacePrecision(_DecimalPlacePrecision_Integer);

Parameters:
x -
y -
_DecimalPlacePrecision_Integer -

Vector_Point2D

public Vector_Point2D(double x,
                      double y,
                      java.math.BigDecimal toRoundToX_BigDecimal,
                      java.math.BigDecimal toRoundToY_BigDecimal)
this._x = VectorStaticBigDecimal.getRounded_BigDecimal( new BigDecimal(x), toRoundToX_BigDecimal); this._y = VectorStaticBigDecimal.getRounded_BigDecimal( new BigDecimal(y), toRoundToY_BigDecimal); set_DecimalPlacePrecision( Math.max( toRoundToX_BigDecimal.scale(), toRoundToY_BigDecimal.scale()));

Parameters:
x -
y -
toRoundToX_BigDecimal -
toRoundToY_BigDecimal -
Method Detail

set_DecimalPlacePrecision

public int set_DecimalPlacePrecision(int _DecimalPlacePrecision)
Description copied from class: Vector_AbstractGeometry2D
Default method probably best overridden to determine what setting _DecimalPlacePrecision_Integer involves

Overrides:
set_DecimalPlacePrecision in class Vector_AbstractGeometry2D
Returns:

roundTo

public void roundTo(java.math.BigDecimal toRoundTo_BigDecimal)

toString

public java.lang.String toString()
Overrides:
toString in class Vector_AbstractGeometry2D

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

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

compareTo

public int compareTo(java.lang.Object o)
Default is 1.

Specified by:
compareTo in interface java.lang.Comparable

getIntersects

public boolean getIntersects(Vector_LineSegment2D a_LineSegment2D,
                             int a_DecimalPlacePrecisionForCalculations)

getDistance

public java.math.BigDecimal getDistance(Vector_Point2D a_VectorPoint2D,
                                        int a_DecimalPlacePrecision)
Precise to a_DecimalPlacePrecision number of decimal places given precision of a_VectorPoint2D and this.

Parameters:
a_VectorPoint2D -
a_DecimalPlacePrecision -
Returns:
The distance from a_VectorPoint2D to this.

getAngle_double

public double getAngle_double(Vector_Point2D a_Point2D)
Imprecise: Uses Java double precision for all calculations

Parameters:
a_Point2D -
Returns:
Angle to the y axis clockwise. Default 0.0d.

getAngle_BigDecimal

public java.math.BigDecimal getAngle_BigDecimal(Vector_Point2D a_Point2D)
Imprecise, but uses BigMath and BigFunction default precision

Parameters:
a_Point2D -
Returns:
Angle to the y axis clockwise. Default 0.0d.

getGradient

public java.math.BigDecimal getGradient(Vector_Point2D a_Point2D,
                                        int a_DecimalPlacePrecision)

getEnvelope2D

public Vector_Envelope2D getEnvelope2D()
Specified by:
getEnvelope2D in class Vector_AbstractGeometry2D

applyDecimalPlacePrecision

public void applyDecimalPlacePrecision()
Specified by:
applyDecimalPlacePrecision in class Vector_AbstractGeometry2D

to_doubleArray

public double[] to_doubleArray()
double[] result = new double[2]; result[0] = this._x.doubleValue(); result[1] = this._y.doubleValue(); return result;

Returns: