org.apache.commons.math3.geometry.euclidean.threed
Class Parallelepiped

java.lang.Object
  extended by org.apache.commons.math3.geometry.euclidean.threed.Parallelepiped
All Implemented Interfaces:
Serializable, CrossSectionProvider, Shape, SolidShape

public final class Parallelepiped
extends Object
implements SolidShape, CrossSectionProvider, Serializable

This is a describing class for a rectangle parallelepiped shape, with some algorithm to compute intersections and distances to some other objects.

Since:
1.0
Version:
$Id: Parallelepiped.java 16755 2016-10-07 15:47:40Z bignon $
Author:
Thomas Trapier
See Also:
Shape.distanceTo(Line), Shape.intersects(Line), Serialized Form
Use sample :

Creation with three Vector3D and two doubles : Parallelepiped parallelepiped = new Parallelepiped(center, vectorU, pseudoVectorV, length, width, height); Intersection with a line : boolean intersects = parallelepiped(line);

Concurrency :
immutable

Constructor Summary
Parallelepiped(Vector3D inCenter, Vector3D inU, Vector3D inV, double inLength, double inWidth, double inHeight)
          Build a parallelepiped from the position of its center, two vectors to describe its local frame and dimensions.
 
Method Summary
 Vector3D[] closestPointTo(Line line)
          Computes the points of the shape and the line realizing the shortest distance.
 double distanceTo(Line line)
          Computes the distance to a line.
 Vector3D getCenter()
           
 Vector3D[] getCorners()
           
 double getCrossSection(Vector3D direction)
          Computes the cross section from the direction defined by a Vector3D.
 Plate[] getFaces()
           
 double getHeight()
           
 Vector3D[] getIntersectionPoints(Line line)
          Compute the intersection points with a line.
 double getLength()
           
 Vector3D getU()
           
 Vector3D getV()
           
 Vector3D getW()
           
 double getWidth()
           
 boolean intersects(Line line)
          Tests the intersection with a line.
 String toString()
          Get a representation for this parallelepiped.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Parallelepiped

public Parallelepiped(Vector3D inCenter,
                      Vector3D inU,
                      Vector3D inV,
                      double inLength,
                      double inWidth,
                      double inHeight)
Build a parallelepiped from the position of its center, two vectors to describe its local frame and dimensions.

Parameters:
inCenter - the center of the plate
inU - a non-normalised vector parallel to u
inV - the second vector defining the plate's plane : corrected to be orthogonal to U
inLength - the parallelepiped's length along U
inWidth - the parallelepiped's width along V (once corrected)
inHeight - the parallelepiped's height
Throws:
IllegalArgumentException - if the vectors do not define a plane, or if the dimensions are negative or null
Method Detail

getCenter

public Vector3D getCenter()
Returns:
the center

getU

public Vector3D getU()
Returns:
the u

getV

public Vector3D getV()
Returns:
the v

getW

public Vector3D getW()
Returns:
the w

getLength

public double getLength()
Returns:
the length

getWidth

public double getWidth()
Returns:
the width

getHeight

public double getHeight()
Returns:
the height

getCorners

public Vector3D[] getCorners()
Returns:
the corners

getFaces

public Plate[] getFaces()
Returns:
the faces

intersects

public boolean intersects(Line line)
Tests the intersection with a line.

Specified by:
intersects in interface Shape
Parameters:
line - the line
Returns:
true if the line intersects the shape

getIntersectionPoints

public Vector3D[] getIntersectionPoints(Line line)
Compute the intersection points with a line.

Specified by:
getIntersectionPoints in interface Shape
Parameters:
line - the line
Returns:
the intersection points if they exist. If no intersection is found, the dimension is zero

distanceTo

public double distanceTo(Line line)
Computes the distance to a line.

Specified by:
distanceTo in interface Shape
Parameters:
line - the line
Returns:
the shortest distance between the the line and the shape

closestPointTo

public Vector3D[] closestPointTo(Line line)
Computes the points of the shape and the line realizing the shortest distance. If the line intersects the shape, the returned points are identical : this point is the first common point found.

Specified by:
closestPointTo in interface Shape
Parameters:
line - the line
Returns:
the two points : first the one from the line, and the one from the shape.

toString

public String toString()
Get a representation for this parallelepiped. The given parameters are in the same order as in the constructor.

Overrides:
toString in class Object
Returns:
a representation for this parallelepiped

getCrossSection

public double getCrossSection(Vector3D direction)
Computes the cross section from the direction defined by a Vector3D.

Specified by:
getCrossSection in interface CrossSectionProvider
Parameters:
direction - the direction vector
Returns:
the cross section


Copyright © 2016 CNES. All Rights Reserved.