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

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

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

Class for a line segment in 2D represented by two Point2D instances, one is designated a start point and the other an end point. In this way a line segment explicitly has a direction. Two Vector_LineSegment2D instances are regarded as equal iff their start and end points are the same.

See Also:
Serialized Form

Field Summary
 Vector_Point2D _End_Point2D
           
 Vector_Point2D _Start_Point2D
           
 
Fields inherited from class uk.ac.leeds.ccg.andyt.vector.geometry.Vector_AbstractGeometry2D
_DecimalPlacePrecision_Integer, _RoundingMode, _Vector_Environment
 
Constructor Summary
Vector_LineSegment2D()
          Creates a default Vector_LineSegment2D with: _Start_Point2D = null; _End_Point2D = null;
Vector_LineSegment2D(Vector_LineSegment2D a_LineSegment2D)
          Creates a Vector_LineSegment2D with: this._Start_Point2D = new Point2D(a_LineSegment2D._Start_Point2D); this._End_Point2D = new Point2D(a_LineSegment2D._End_Point2D); this._DecimalPlacePrecision_Integer = a_LineSegment2D._DecimalPlacePrecision_Integer;
Vector_LineSegment2D(Vector_Point2D _StartPoint, Vector_Point2D _EndPoint)
          Creates a Vector_LineSegment2D with: this._Start_Point2D = new Point2D(_StartPoint); this._End_Point2D = new Point2D(_EndPoint); set_DecimalPlacePrecision(Math.max( _Start_Point2D.get_DecimalPlacePrecision(), _End_Point2D.get_DecimalPlacePrecision()));
Vector_LineSegment2D(Vector_Point2D _StartPoint, Vector_Point2D _EndPoint, int _DecimalPlacePrecision)
          Creates a Vector_LineSegment2D with: _StartPoint = _StartPoint; _EndPoint = _EndPoint; _DecimalPlacePrecision_Integer = _DecimalPlacePrecision_Integer; _RoundingMode = _RoundingMode.
 
Method Summary
 void applyDecimalPlacePrecision()
           
 int compareTo(java.lang.Object o)
          Default is 1.
 double getAngleToX_double()
           
 double getAngleToY_double()
           
 java.math.BigDecimal getCrossProduct(Vector_LineSegment2D a_LineSegment2D)
          Assuming a_LineSegment.StartPoint == this.
 Vector_Envelope2D getEnvelope2D()
           
protected  java.math.BigDecimal getGradient(int a_DecimalPlacePrecision)
           
 Vector_AbstractGeometry2D getIntersection(Vector_LineSegment2D a_LineSegment2D, int a_DecimalPlacePrecision)
          Intersection method adapted from http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
 boolean getIntersects(Vector_LineSegment2D a_LineSegment2D, boolean ignore_this_Start_Point2D, int a_DecimalPlacePrecision)
          For optimisation reasons, intersection done by first seeing if there is Envelope intersection...
 boolean getIntersects(Vector_LineSegment2D a_LineSegment2D, int a_DecimalPlacePrecision)
          Intersection done by first seeing if Envelope intersection....
 boolean getIntersects(Vector_Point2D a_Point2D, int a_DecimalPlacePrecision)
          Intersection done by calculating angle or gradient of the line and comparing this with that of a_Point.
 java.math.BigDecimal getLength(int a_DecimalPlacePrecision)
           
 Vector_LineSegment2D getOrderedLineSegment2D()
           
 java.math.BigDecimal getScalarProduct(Vector_LineSegment2D a_LineSegment2D)
          Assuming a_LineSegment.StartPoint == this.
protected  boolean isOnGradient(Vector_Point2D a_Point2D, int a_DecimalPlacePrecision)
           
 int set_DecimalPlacePrecision(int _DecimalPlacePrecision)
          Default method probably best overridden to determine what setting _DecimalPlacePrecision_Integer involves
 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, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_Start_Point2D

public Vector_Point2D _Start_Point2D

_End_Point2D

public Vector_Point2D _End_Point2D
Constructor Detail

Vector_LineSegment2D

public Vector_LineSegment2D()
Creates a default Vector_LineSegment2D with: _Start_Point2D = null; _End_Point2D = null;


Vector_LineSegment2D

public Vector_LineSegment2D(Vector_Point2D _StartPoint,
                            Vector_Point2D _EndPoint)
Creates a Vector_LineSegment2D with: this._Start_Point2D = new Point2D(_StartPoint); this._End_Point2D = new Point2D(_EndPoint); set_DecimalPlacePrecision(Math.max( _Start_Point2D.get_DecimalPlacePrecision(), _End_Point2D.get_DecimalPlacePrecision()));

Parameters:
_StartPoint -
_EndPoint -

Vector_LineSegment2D

public Vector_LineSegment2D(Vector_Point2D _StartPoint,
                            Vector_Point2D _EndPoint,
                            int _DecimalPlacePrecision)
Creates a Vector_LineSegment2D with: _StartPoint = _StartPoint; _EndPoint = _EndPoint; _DecimalPlacePrecision_Integer = _DecimalPlacePrecision_Integer; _RoundingMode = _RoundingMode.

Parameters:
_StartPoint -
_EndPoint -
_DecimalPlacePrecision_Integer -
_RoundingMode -

Vector_LineSegment2D

public Vector_LineSegment2D(Vector_LineSegment2D a_LineSegment2D)
Creates a Vector_LineSegment2D with: this._Start_Point2D = new Point2D(a_LineSegment2D._Start_Point2D); this._End_Point2D = new Point2D(a_LineSegment2D._End_Point2D); this._DecimalPlacePrecision_Integer = a_LineSegment2D._DecimalPlacePrecision_Integer;

Parameters:
_StartPoint -
_EndPoint -
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:

toString

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

compareTo

public int compareTo(java.lang.Object o)
Default is 1. Calls compareTo on the _StartPoint.

Specified by:
compareTo in interface java.lang.Comparable

getLength

public java.math.BigDecimal getLength(int a_DecimalPlacePrecision)
Parameters:
a_DecimalPlacePrecision -
Returns:
The length of this as a BigDecimal

getEnvelope2D

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

getIntersects

public boolean getIntersects(Vector_LineSegment2D a_LineSegment2D,
                             int a_DecimalPlacePrecision)
Intersection done by first seeing if Envelope intersection....

Parameters:
a_LineSegment2D -
Returns:
true iff a_LineSegment2D getIntersects this.

getIntersects

public boolean getIntersects(Vector_LineSegment2D a_LineSegment2D,
                             boolean ignore_this_Start_Point2D,
                             int a_DecimalPlacePrecision)
For optimisation reasons, intersection done by first seeing if there is Envelope intersection...

Parameters:
a_LineSegment2D -
ignore_this_Start_Point2D - if true then if this._Start_Point2D.getIntersects(a_LineSegment2D) return false
Returns:
true iff a_LineSegment2D getIntersects this.

getIntersects

public boolean getIntersects(Vector_Point2D a_Point2D,
                             int a_DecimalPlacePrecision)
Intersection done by calculating angle or gradient of the line and comparing this with that of a_Point.

Parameters:
a_Point2D -
Returns:
true iff a_Point2D getIntersects this.

getGradient

protected java.math.BigDecimal getGradient(int a_DecimalPlacePrecision)

isOnGradient

protected boolean isOnGradient(Vector_Point2D a_Point2D,
                               int a_DecimalPlacePrecision)

getOrderedLineSegment2D

public Vector_LineSegment2D getOrderedLineSegment2D()

getIntersection

public Vector_AbstractGeometry2D getIntersection(Vector_LineSegment2D a_LineSegment2D,
                                                 int a_DecimalPlacePrecision)
Intersection method adapted from http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/

Returns:
null if this does not intersect a_LineSegment2D; a Point2D if this getIntersects a_LineSegment2D at a point; and, a Vector_LineSegment2D if this getIntersects a_LineSegment2D in a line.

getAngleToX_double

public double getAngleToX_double()
Returns:
The angle in radians to the X axis

getAngleToY_double

public double getAngleToY_double()
Returns:
The angle in radians to the Y axis

getScalarProduct

public java.math.BigDecimal getScalarProduct(Vector_LineSegment2D a_LineSegment2D)
Assuming a_LineSegment.StartPoint == this.

Parameters:
a_LineSegment2D -
Returns:

getCrossProduct

public java.math.BigDecimal getCrossProduct(Vector_LineSegment2D a_LineSegment2D)
Assuming a_LineSegment.StartPoint == this.

Parameters:
a_LineSegment2D -
Returns:

applyDecimalPlacePrecision

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