org.starhope.appius.geometry
Class LineSeg3D

java.lang.Object
  extended by org.starhope.appius.geometry.LineSeg3D
Direct Known Subclasses:
Vector3D

public class LineSeg3D
extends Object

A simple line segment with two endpoints (expressed as Coord3D)

Author:
brpocock@star-hope.org

Field Summary
protected  Coord3D a
          The start of the line
protected  Coord3D b
          The end of the line
 
Constructor Summary
LineSeg3D(Coord3D start, Coord3D end)
          Construct a line segment with the given start and end points
 
Method Summary
 LineSeg3D add(Coord3D delta)
          translate the line segment's end points by the amount of the coördinates provided
 Vector3D asVector()
           
 boolean equals(Object obj)
           
 Coord3D getEnd()
          Get the final (B) coördinates of this segment
 Coord3D getStart()
          Get the initial (A) coördinates of this segment
 boolean hasEndpoint(Coord3D p)
           
 int hashCode()
           
 LineSeg3D toOrigin()
          Create a copy of the line transformed so that it starts at the origin.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

a

protected final Coord3D a
The start of the line


b

protected final Coord3D b
The end of the line

Constructor Detail

LineSeg3D

public LineSeg3D(Coord3D start,
                 Coord3D end)
Construct a line segment with the given start and end points

Parameters:
start - the start (A) coördinates
end - the end (B) coördinates
Method Detail

add

public LineSeg3D add(Coord3D delta)
translate the line segment's end points by the amount of the coördinates provided

Parameters:
delta - the amount to alter the line segment
Returns:
the line offset by the given delta

asVector

public Vector3D asVector()
Returns:
a vector matching this line segment in origin and magnitude

equals

public boolean equals(Object obj)
Overrides:
equals in class Object
See Also:
Note, two lines are equal if (and only if) they share the same two endpoints; however, a line from A to B is identical to a line from B to A for these purposes.

getEnd

public Coord3D getEnd()
Get the final (B) coördinates of this segment

Returns:
the coördinates of the end of the line segment

getStart

public Coord3D getStart()
Get the initial (A) coördinates of this segment

Returns:
the coördinates of the start of the line segment

hasEndpoint

public boolean hasEndpoint(Coord3D p)
Parameters:
p - any point
Returns:
true, if the point is one of the endpoints (start or end) of this line

hashCode

public int hashCode()
Overrides:
hashCode in class Object
See Also:
Object.hashCode()

toOrigin

public LineSeg3D toOrigin()
Create a copy of the line transformed so that it starts at the origin.

Returns:
the copy