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

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

public final class SphericalCap
extends Object
implements SolidShape

Implements a representation of a spherical cap solid.

This class implements the SolidShape interface, so it provides the expected : intersection with a line, distance from the surface of the shape, intersection points...

Since:
1.0
Version:
$Id: SphericalCap.java 17583 2017-05-10 13:05:10Z bignon $
Author:
cardosop
See Also:
SolidShape
Use sample :

// A half-sphere :
// - sphere at the origin, radius 1.
// - plane (x,y), the normal is the z unit vector
final Sphere originSphere = new Sphere(new Vector3D(0., 0., 0.) , 1.);
final Plane xyPlane = new Plane(new Vector3D(0., 0., 1.));
final SphericalCap halfSphere = new SphericalCap(originSphere, xyPlane);

Concurrency :
immutable

Constructor Summary
SphericalCap(Sphere s, Plane p)
          Constructor of a SphericalCap using a Sphere and a Plane.
 
Method Summary
 Vector3D[] closestPointTo(Line line)
          Computes the points of the shape and the line realizing the shortest distance.
 double distanceTo(Line line)
          Gives the distance from the line to the spherical cap.
When the line intersects the spherical cap, the distance is 0.
 Vector3D[] getIntersectionPoints(Line line)
          Returns a list of intersection points between the line and the spherical cap.
Only the border points are given.
 boolean intersects(Line line)
          Returns true when the line intersects the spherical cap.
 String toString()
          Get a representation for this sphere.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SphericalCap

public SphericalCap(Sphere s,
                    Plane p)
Constructor of a SphericalCap using a Sphere and a Plane.

Parameters:
s - the sphere enclosing the spherical cap
p - plane delimiting the spherical cap. This plane must intersect with the sphere by more than a single point, if not the spherical cap is considered undefined. The direction of the plane is used to determine in which side the spherical cap is : it is on the side of the normal vector.
Since:
1.0
Method Detail

intersects

public boolean intersects(Line line)
Returns true when the line intersects the spherical cap.

Specified by:
intersects in interface Shape
Parameters:
line - to intersect
Returns:
true when the line intersects the spherical cap
See Also:
Shape.intersects(Line)

distanceTo

public double distanceTo(Line line)
Gives the distance from the line to the spherical cap.
When the line intersects the spherical cap, the distance is 0.

Specified by:
distanceTo in interface Shape
Parameters:
line - to get the distance from
Returns:
the distance (>=0)
See Also:
Shape.distanceTo(Line)

getIntersectionPoints

public Vector3D[] getIntersectionPoints(Line line)
Returns a list of intersection points between the line and the spherical cap.
Only the border points are given. Since the spherical cap is convex, there will always be at most two points returned by this method.
When there are none, an empty array is returned.

Specified by:
getIntersectionPoints in interface Shape
Parameters:
line - to intersect
Returns:
an array of intersection points.
See Also:
Shape.getIntersectionPoints(Line)

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 sphere. The given parameters are in the same order as in the constructor.

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


Copyright © 2017 CNES. All Rights Reserved.