maspack.geometry
Class LineSegment

java.lang.Object
  extended by maspack.geometry.LineSegment
All Implemented Interfaces:
Boundable

public class LineSegment
extends java.lang.Object
implements Boundable


Field Summary
 Vertex3d myVtx0
           
 Vertex3d myVtx1
           
 
Constructor Summary
LineSegment(Vertex3d vtx0, Vertex3d vtx1)
           
 
Method Summary
 void computeCentroid(Vector3d centroid)
          Computed the centroid of this element.
 double computeCovariance(Matrix3d C)
          Computes covariance of this line segment and returns its length.
 double getLength()
           
 Point3d getPoint(int idx)
          Returns the idx-th point associated with this element.
 int numPoints()
          Returns the number of points associated with this element, if any, or zero otherwise.
 void updateBounds(Point3d min, Point3d max)
          Updates the axis-aligned bounds of this element.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myVtx0

public Vertex3d myVtx0

myVtx1

public Vertex3d myVtx1
Constructor Detail

LineSegment

public LineSegment(Vertex3d vtx0,
                   Vertex3d vtx1)
Method Detail

computeCentroid

public void computeCentroid(Vector3d centroid)
Description copied from interface: Boundable
Computed the centroid of this element.

Specified by:
computeCentroid in interface Boundable
Parameters:
centroid - returns the computed centroid value.

computeCovariance

public double computeCovariance(Matrix3d C)
Computes covariance of this line segment and returns its length.

The formula was determined by substituting the the parametric form for x

 x = (1-s) p0 + s p1
 
into the general formula for C
 C = \int_V \rho x x^T dV
 
and evaluating the integral over the s interval [0,1].

Specified by:
computeCovariance in interface Boundable
Parameters:
C - returns the covariance
Returns:
length of the line segment

getLength

public double getLength()

updateBounds

public void updateBounds(Point3d min,
                         Point3d max)
Description copied from interface: Boundable
Updates the axis-aligned bounds of this element. The value in min and max should be decreased or increased, respectively, so that all spatial points associated with this element lie within the axis-aligned box defined by min and max.

Specified by:
updateBounds in interface Boundable
Parameters:
min - minimum values to be updated
max - maximum values to be updated

numPoints

public int numPoints()
Description copied from interface: Boundable
Returns the number of points associated with this element, if any, or zero otherwise. If the element has points, then it's spatial extent is assumed to be enclosed within their convex hull. At present, elements that do not have points cannot be enclosed within oriented bounding box (OBB) trees.

Specified by:
numPoints in interface Boundable
Returns:
number of points associated with this element

getPoint

public Point3d getPoint(int idx)
Description copied from interface: Boundable
Returns the idx-th point associated with this element.

Specified by:
getPoint in interface Boundable
Parameters:
idx - index of the point (must be on the range 0 to Boundable.numPoints()).
Returns:
idx-th point associated with this element. Must not be modified.