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

java.lang.Object
  extended by edu.stanford.rsl.konrad.geometry.AbstractShape
      extended by edu.stanford.rsl.konrad.geometry.AbstractSurface
          extended by edu.stanford.rsl.konrad.geometry.shapes.simple.Plane3D
              extended by edu.stanford.rsl.konrad.geometry.shapes.simple.Triangle
All Implemented Interfaces:
Transformable, java.io.Serializable

public class Triangle
extends Plane3D

Class to describe a triangle in 3D.

Author:
akmaier
See Also:
Serialized Form

Constructor Summary
Triangle(PointND a, PointND b, PointND c)
          Creates a new Triangle from the Points a, b, and c
 
Method Summary
 void applyTransform(Transform t)
          Applies the Transform t to the object.
 PointND getA()
          Returns point a
 PointND getB()
          Returns point b
 PointND getC()
          Returns point c
 java.util.ArrayList<PointND> getHitsOnBoundingBox(AbstractCurve other)
           
 PointND[] getRasterPoints(int number)
          Rasters the shape with a given number of points or less.
 java.util.ArrayList<PointND> intersect(AbstractCurve other)
          Returns the intersection points between the curve and the shape.
 PointND intersect(StraightLine other)
           
 boolean isBounded()
          Returns true if the shape is of limited space
 boolean isInTriangle(PointND p)
          Computes whether the given point is inside of the triangle.
 java.lang.String toString()
           
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.shapes.simple.Plane3D
computeDistance, computeDistance, evaluate, flipNormal, getDimension, getNormal, getPoint, orientNormal
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractSurface
evaluate, getInternalDimension
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractShape
getHitsOnBoundingBox_slow, getMax, getMin
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Triangle

public Triangle(PointND a,
                PointND b,
                PointND c)
Creates a new Triangle from the Points a, b, and c

Parameters:
a -
b -
c -
Method Detail

getHitsOnBoundingBox

public java.util.ArrayList<PointND> getHitsOnBoundingBox(AbstractCurve other)
Overrides:
getHitsOnBoundingBox in class AbstractShape

getA

public PointND getA()
Returns point a

Returns:
point a

getB

public PointND getB()
Returns point b

Returns:
point b

getC

public PointND getC()
Returns point c

Returns:
point c

intersect

public PointND intersect(StraightLine other)
Overrides:
intersect in class Plane3D

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.

Overrides:
intersect in class Plane3D
Returns:
the intersection points.

isInTriangle

public boolean isInTriangle(PointND p)
Computes whether the given point is inside of the triangle. Implementation is based on barycentric coordinates.

Parameters:
p - the point
Returns:
true if it is inside of the triangle.

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.

Overrides:
getRasterPoints in class Plane3D
Parameters:
number - the number of points
Returns:
the raster points

isBounded

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

Overrides:
isBounded in class Plane3D
Returns:
Boundedness of this shape.

applyTransform

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

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

toString

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