ProGAL.geom3d
Class LineSegment

java.lang.Object
  extended by ProGAL.geom3d.LineSegment
All Implemented Interfaces:
Shape, Simplex
Direct Known Subclasses:
CEdge

public class LineSegment
extends java.lang.Object
implements Simplex

A line segment spanned by two points, a and b.


Constructor Summary
LineSegment(Point a, Point b)
          Constructs a segment between points a and b.
LineSegment(Point a, Vector v)
          Constructs a segment from a to a+v.
 
Method Summary
 LineSegment clone()
          Returns a deep clone of this line segment.
 boolean equals(LineSegment ls)
          Returns true iff this line-segment and ls are the same.
 boolean equals(java.lang.Object o)
          Returns true iff the argument is a line-segment and equals this.
 Point getA()
          Get the first point spanning the segment.
 Vector getAToB()
          Get the direction of the segment.
 Point getB()
          Get the second point spanning the segment.
 Point getCenter()
          Returns the mid-point of this line-segment.
 Point getClosestPoint(Point q)
          Get the point on the segment closest to a given point q.
 int getDimension()
          Return the 'dimension' of this object.
 double getDistance(Point q)
          Gets the distance from q to the nearest point on this segment.
 double getLength()
          Get the length of the segment.
 double getLengthSquared()
          Get the squared length of the segment.
 Point getMidPoint()
          Gets the midpoint of the segment.
 Point getPoint(int i)
          TODO: Comment and test
 double getSquaredDistance(Point q)
          Gets the squared distance from q to the nearest point on this segment.
 void setA(Point a)
          Change the first point spanning the segment.
 void setB(Point b)
          Change the second point spanning the segment.
 void toConsole()
          Writes this segment to System.out.
 void toConsole(int dec)
          Writes this segment to System.out with dec decimals precision.
 void toScene(J3DScene scene, double r, java.awt.Color clr)
           
 java.lang.String toString()
          Returns a string representation of this segments.
 java.lang.String toString(int dec)
          Returns a string representation of this segments with dec decimals precision.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LineSegment

public LineSegment(Point a,
                   Point b)
Constructs a segment between points a and b.


LineSegment

public LineSegment(Point a,
                   Vector v)
Constructs a segment from a to a+v.

Method Detail

getA

public Point getA()
Get the first point spanning the segment.


getB

public Point getB()
Get the second point spanning the segment.


setA

public void setA(Point a)
Change the first point spanning the segment.


setB

public void setB(Point b)
Change the second point spanning the segment.


getAToB

public Vector getAToB()
Get the direction of the segment. This method returns a new object.


getLength

public double getLength()
Get the length of the segment.


getLengthSquared

public double getLengthSquared()
Get the squared length of the segment.


getClosestPoint

public Point getClosestPoint(Point q)
Get the point on the segment closest to a given point q. This method always returns a new object.


getSquaredDistance

public double getSquaredDistance(Point q)
Gets the squared distance from q to the nearest point on this segment.


getDistance

public double getDistance(Point q)
Gets the distance from q to the nearest point on this segment.


getMidPoint

public Point getMidPoint()
Gets the midpoint of the segment.


getCenter

public Point getCenter()
Returns the mid-point of this line-segment. Since a line-segment can be interpreted as a geometric shape (a 1-simplex) the Shape interface requires the getCenter method to be implemented. TODO: Test

Specified by:
getCenter in interface Shape

getPoint

public Point getPoint(int i)
TODO: Comment and test

Specified by:
getPoint in interface Simplex

getDimension

public int getDimension()
Return the 'dimension' of this object. Required by the interface Simplex.

Specified by:
getDimension in interface Simplex

equals

public boolean equals(java.lang.Object o)
Returns true iff the argument is a line-segment and equals this.

Overrides:
equals in class java.lang.Object

equals

public boolean equals(LineSegment ls)
Returns true iff this line-segment and ls are the same. Two line-segments are not considered equal if they have the same end-points but in different orders.


clone

public LineSegment clone()
Returns a deep clone of this line segment.

Overrides:
clone in class java.lang.Object

toString

public java.lang.String toString()
Returns a string representation of this segments.

Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(int dec)
Returns a string representation of this segments with dec decimals precision.


toConsole

public void toConsole()
Writes this segment to System.out.


toConsole

public void toConsole(int dec)
Writes this segment to System.out with dec decimals precision.


toScene

public void toScene(J3DScene scene,
                    double r,
                    java.awt.Color clr)