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

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
All Implemented Interfaces:
Transformable, java.io.Serializable
Direct Known Subclasses:
Triangle

public class Plane3D
extends AbstractSurface

There are 3 representations for a plane:

All these representations are stored internally and can be requested as soon as the plane has been created (using any form of constructor).

See Also:
Serialized Form

Constructor Summary
Plane3D(PointND... points)
          Initializes the plane to the one with minimum sum of squared distances from all given points.
Plane3D(PointND point, SimpleVector normal)
          Creates a plane from a given point in the plane and a vector normal to the plane so that $\{ \mathbf x : \mathbf{n}^T (\mathbf x - \mathbf P) = 0 \}$.
Plane3D(PointND p1, SimpleVector dirU, SimpleVector dirV)
          Creates a plane from the given parametric representation $\mathbf P + \alpha \cdot \mathbf u + \beta \cdot \mathbf v, \quad \alpha, \beta \in \mathbb R$.
Plane3D(SimpleVector normal, double offset)
          Creates a plane from the given normal form $\{ \mathbf x : \mathbf{n}^T \mathbf x = d \}$.
 
Method Summary
 void applyTransform(Transform t)
          Applies the Transform t to the object.
 double computeDistance(PointND givenPoint)
          Computes the distance of a point to this plane.
 double computeDistance(PointND givenPoint, PointND closestPoint)
          Computes the distance of a point to this plane and returns the closest point to the given point on the plane.
 PointND evaluate(double u, double v)
          Returns a point on the surface at position (u, v).
 void flipNormal()
          flip the normal of the plane
 int getDimension()
          Returns the external dimension of the shape.
 SimpleVector getNormal()
           
 PointND getPoint()
           
 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 l)
           
 boolean isBounded()
          Returns true if the shape is of limited space
 void orientNormal(boolean fromOriginToPlane)
          Orient the normal either from the origin to the plane or in the opposite direction.
 
Methods inherited from class edu.stanford.rsl.konrad.geometry.AbstractSurface
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, toString, wait, wait, wait
 

Constructor Detail

Plane3D

public Plane3D(PointND p1,
               SimpleVector dirU,
               SimpleVector dirV)
Creates a plane from the given parametric representation $\mathbf P + \alpha \cdot \mathbf u + \beta \cdot \mathbf v, \quad \alpha, \beta \in \mathbb R$.

Parameters:
p1 - An arbitrary point in the plane.
dirU - A first direction vector in the plane.
dirV - A second direction vector in the plane which is not colinear with the first vector.

Plane3D

public Plane3D(SimpleVector normal,
               double offset)
Creates a plane from the given normal form $\{ \mathbf x : \mathbf{n}^T \mathbf x = d \}$. Note that the given normal vector is normalized and stored as a unit vector.

Parameters:
normal - A vector that is normal to the plane.
offset - The offset from the coordinate system's origin to this plane in the normal direction. This offset value is negative if the normal does not point from the origin to the plane but in the opposite direction.

Plane3D

public Plane3D(PointND point,
               SimpleVector normal)
Creates a plane from a given point in the plane and a vector normal to the plane so that $\{ \mathbf x : \mathbf{n}^T (\mathbf x - \mathbf P) = 0 \}$. This representation is called mixed form here. Note that the given normal vector is normalized and stored as a unit vector.

Parameters:
point - Any point in the plane.
normal - A vector normal to the plane.

Plane3D

public Plane3D(PointND... points)
Initializes the plane to the one with minimum sum of squared distances from all given points.

Parameters:
points - The array or comma-separated list of points this plane should be fitted to.
Method Detail

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

evaluate

public PointND evaluate(double u,
                        double v)
Description copied from class: AbstractSurface
Returns a point on the surface at position (u, v). u, v in [0, 1];

Specified by:
evaluate in class AbstractSurface
Parameters:
u - the internal position in u dimension
v - the internal position in v dimension
Returns:
the surface point

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 l)

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.

orientNormal

public void orientNormal(boolean fromOriginToPlane)
Orient the normal either from the origin to the plane or in the opposite direction. If the normal points from the direction to the plane, then the offset parameter d will be positive. Otherwise it will be negative.

Parameters:
fromOriginToPlane - specifies the direction in which to orient the plane.

computeDistance

public double computeDistance(PointND givenPoint)
Computes the distance of a point to this plane.

Parameters:
givenPoint - The point whose distance is to be computed and whose closest neighbor on the plane is to be determined.
Returns:
The signed distance of the given point to this plane. The plane's unit normal vector has to be multiplied with this signed distance to get from the closest point to the given point, i.e.
\[ \mathbf{G} = \mathbf{C} + d \cdot \mathbf{n} \]
where G is the given point, C the closest point on the plane, and n the plane's normal.

computeDistance

public double computeDistance(PointND givenPoint,
                              PointND closestPoint)
Computes the distance of a point to this plane and returns the closest point to the given point on the plane.

Parameters:
givenPoint - The point whose distance is to be computed and whose closest neighbor on the plane is to be determined.
closestPoint - The closest point to the given one on this plane is returned here.
Returns:
The signed distance of the given point to this plane. The plane's unit normal vector has to be multiplied with this signed distance to get from the closest point to the given point, i.e.
\[ \mathbf{G} = \mathbf{C} + d \cdot \mathbf{n} \]
where G is the given point, C the closest point on the plane, and n the plane's normal.

flipNormal

public void flipNormal()
flip the normal of the plane


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

getNormal

public SimpleVector getNormal()

getPoint

public PointND getPoint()