physics
Class LineSegment

java.lang.Object
  extended by physics.LineSegment
All Implemented Interfaces:
java.io.Serializable

public final class LineSegment
extends java.lang.Object
implements java.io.Serializable

LineSegment is an immutable abstract data type which represents a line segment in two dimensional Cartesian space.

See Also:
Serialized Form

Constructor Summary
LineSegment(double x1, double y1, double x2, double y2)
           
LineSegment(java.awt.geom.Line2D l2d)
           
LineSegment(Vect p1, Vect p2)
           
 
Method Summary
 Angle angle()
           
 boolean equals(LineSegment ls)
           
 boolean equals(java.lang.Object o)
           
 int hashCode()
           
 double length()
           
 Vect p1()
           
 Vect p2()
           
 java.awt.geom.Line2D.Double toLine2D()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineSegment

public LineSegment(Vect p1,
                   Vect p2)

LineSegment

public LineSegment(java.awt.geom.Line2D l2d)

LineSegment

public LineSegment(double x1,
                   double y1,
                   double x2,
                   double y2)
Method Detail

p1

public Vect p1()
Returns:
the first point of this line segment.

p2

public Vect p2()
Returns:
the second point of this line segment.

toLine2D

public java.awt.geom.Line2D.Double toLine2D()
Returns:
a new Line2D representing this

angle

public Angle angle()
Returns:
the angle from the x-axis of this.

length

public double length()
Returns:
the length of this.

toString

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

equals

public boolean equals(LineSegment ls)

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