edu.stanford.rsl.konrad.geometry.shapes.simple
Class StraightLine

java.lang.Object
  extended by edu.stanford.rsl.konrad.geometry.AbstractShape
      extended by edu.stanford.rsl.konrad.geometry.AbstractCurve
          extended by edu.stanford.rsl.konrad.geometry.shapes.simple.StraightLine
All Implemented Interfaces:
Transformable, java.io.Serializable
Direct Known Subclasses:
Edge

public class StraightLine
extends AbstractCurve

See Also:
Serialized Form

Constructor Summary
StraightLine(PointND point, PointND point2)
          Creates a new Straight line passing from point to point2
StraightLine(PointND point, SimpleVector dir)
          Creates a StraightLine from point with direction dir
 
Method Summary
 void applyTransform(Transform t)
          Applies the Transform t to the object.
 double computeDistanceTo(PointND p)
          Computes the closest distance between the line and the point p.
 PointND evaluate(double u)
          Returns a point on the Curve at position u [0, 1];
 int getDimension()
          Returns the external dimension of the shape.
 SimpleVector getDirection()
           
 PointND getPoint()
           
 PointND[] getRasterPoints(int number)
          Rasters the shape with a given number of points or less.
 void init(PointND point, PointND point2)
           
 void init(PointND point, SimpleVector dir)
           
 java.util.ArrayList<PointND> intersect(AbstractCurve other)
          Returns the intersection points between the curve and the shape.
 PointND intersect(StraightLine line)
           
 boolean isBounded()
          Returns true if the shape is of limited space
 void normalize()
           
 void setDirection(SimpleVector direction)
           
 void setPoint(PointND point)
           
 java.lang.String toString()
           
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractCurve
evaluate, getInternalDimension
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractShape
getHitsOnBoundingBox_slow, getHitsOnBoundingBox, getMax, getMin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

StraightLine

public StraightLine(PointND point,
                    SimpleVector dir)
Creates a StraightLine from point with direction dir

Parameters:
point - the point
dir - the direction

StraightLine

public StraightLine(PointND point,
                    PointND point2)
Creates a new Straight line passing from point to point2

Parameters:
point - the base point
point2 - the other point
Method Detail

init

public void init(PointND point,
                 SimpleVector dir)

init

public void init(PointND point,
                 PointND point2)

normalize

public void normalize()

evaluate

public PointND evaluate(double u)
Description copied from class: AbstractCurve
Returns a point on the Curve at position u [0, 1];

Specified by:
evaluate in class AbstractCurve
Parameters:
u - the internal position
Returns:
the curve point

getDimension

public int getDimension()
Description copied from class: AbstractShape
Returns the external dimension of the shape.

Specified by:
getDimension in class AbstractShape
Returns:
the dimension

intersect

public java.util.ArrayList<PointND> intersect(AbstractCurve other)
Description copied from class: AbstractShape
Returns the intersection points between the curve and the shape. Returns null, if the intersection is empty.

Specified by:
intersect in class AbstractShape
Returns:
the intersection points.

intersect

public PointND intersect(StraightLine line)

getDirection

public SimpleVector getDirection()
Returns:
the direction

setDirection

public void setDirection(SimpleVector direction)
Parameters:
direction - the direction to set

getPoint

public PointND getPoint()
Returns:
the point

setPoint

public void setPoint(PointND point)
Parameters:
point - the point to set

isBounded

public boolean isBounded()
Description copied from class: AbstractShape
Returns true if the shape is of limited space

Specified by:
isBounded in class AbstractShape
Returns:
Boundedness of this shape.

computeDistanceTo

public double computeDistanceTo(PointND p)
Computes the closest distance between the line and the point p.

Parameters:
p - the point p
Returns:
the distance

applyTransform

public void applyTransform(Transform t)
Description copied from interface: Transformable
Applies the Transform t to the object.

Specified by:
applyTransform in interface Transformable
Specified by:
applyTransform in class AbstractShape
Parameters:
t - the transform to apply to the object.

getRasterPoints

public PointND[] getRasterPoints(int number)
Description copied from class: AbstractShape
Rasters the shape with a given number of points or less. If the shape is not bounded null is returned.

Specified by:
getRasterPoints in class AbstractShape
Parameters:
number - the number of points
Returns:
the raster points

toString

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