Package gov.nasa.worldwind.geom
Class Cylinder
- java.lang.Object
-
- gov.nasa.worldwind.geom.Cylinder
-
- All Implemented Interfaces:
Extent
,Renderable
public class Cylinder extends java.lang.Object implements Extent, Renderable
Represents a geometric cylinder, most often used as a bounding volume.Cylinder
s are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description protected Vec4
axisUnitDirection
protected Vec4
bottomCenter
protected double
cylinderHeight
protected double
cylinderRadius
protected Vec4
topCenter
-
Constructor Summary
Constructors Constructor Description Cylinder(Vec4 bottomCenter, Vec4 topCenter, double cylinderRadius)
Create a Cylinder from two points and a radius.Cylinder(Vec4 bottomCenter, Vec4 topCenter, double cylinderRadius, Vec4 unitDirection)
Create a Cylinder from two points, a radius and an axis direction.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
clipcyl(Vec4 raybase, Vec4 raycos, Vec4 bot, Vec4 top, Vec4 axis, double[] tVals)
static Cylinder
computeBoundingCylinder(java.lang.Iterable<? extends Vec4> points)
Compute a bounding cylinder for a collection of points.static Cylinder
computeVerticalBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector)
Returns a cylinder that minimally surrounds the specified minimum and maximum elevations in the sector at a specified vertical exaggeration, and is oriented such that the cylinder axis is perpendicular to the globe's surface.static Cylinder
computeVerticalBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector, double minElevation, double maxElevation)
Returns a cylinder that minimally surrounds the specified minimum and maximum elevations in the sector at a specified vertical exaggeration, and is oriented such that the cylinder axis is perpendicular to the globe's surface.protected static Cylinder
computeVerticalBoundsFromSectorLatitudeRange(Globe globe, Sector sector, double minHeight, double maxHeight)
Compute the Cylinder that surrounds the equator, and has height defined by the sector's minumum and maximum latitudes (including maxHeight).protected static Cylinder
computeVerticalBoundsFromSectorQuadrilateral(Globe globe, Sector sector, double minHeight, double maxHeight)
Returns a cylinder that minimally surrounds the specified height range in the sector.protected static Cylinder
computeVerticalBoundsFromSectorVertices(Globe globe, Sector sector, double minHeight, double maxHeight)
Returns a cylinder that surrounds the specified height range in the zero-area sector.boolean
equals(java.lang.Object o)
Vec4
getAxisUnitDirection()
Returns the unit-length axis of this cylinder.Vec4
getBottomCenter()
Returns the this cylinder's bottom-center point.Vec4
getCenter()
Return this cylinder's center point.double
getCylinderHeight()
Returns this cylinder's height.double
getCylinderRadius()
Returns this cylinder's radius.double
getDiameter()
Returns the extent's diameter.double
getEffectiveRadius(Plane plane)
Computes the effective radius of the extent relative to a specified plane.double
getProjectedArea(View view)
Computes the area in square pixels of thisExtent
after it is projected into the specifiedview's
viewport.double
getRadius()
Returns the extent's radius.Vec4
getTopCenter()
Returns the this cylinder's top-center point.double
getVolume()
Return this cylinder's volume.int
hashCode()
protected boolean
intcyl(Vec4 raybase, Vec4 raycos, Vec4 base, Vec4 axis, double radius, double[] tVals)
Intersection[]
intersect(Line line)
Computes the intersections of this extent withline
.boolean
intersects(Frustum frustum)
Determines whether or not thisExtent
intersectsfrustum
.boolean
intersects(Line line)
Determines whether or notline
intersects thisExtent
.boolean
intersects(Plane plane)
Calculate whether or not thisExtent
is intersected byplane
.protected double
intersects(Plane plane, double effectiveRadius)
protected double
intersectsAt(Plane plane, double effectiveRadius, Vec4[] endpoints)
void
render(DrawContext dc)
Display the cylinder.java.lang.String
toString()
-
-
-
Constructor Detail
-
Cylinder
public Cylinder(Vec4 bottomCenter, Vec4 topCenter, double cylinderRadius)
Create a Cylinder from two points and a radius.- Parameters:
bottomCenter
- the center point of of the cylinder's base.topCenter
- the center point of the cylinders top.cylinderRadius
- the cylinder's radius.- Throws:
java.lang.IllegalArgumentException
- if the radius is zero or the top or bottom point is null or they are coincident.
-
Cylinder
public Cylinder(Vec4 bottomCenter, Vec4 topCenter, double cylinderRadius, Vec4 unitDirection)
Create a Cylinder from two points, a radius and an axis direction. Provided for use when unit axis is know and computation of it can be avoided.- Parameters:
bottomCenter
- the center point of of the cylinder's base.topCenter
- the center point of the cylinders top.cylinderRadius
- the cylinder's radius.unitDirection
- the unit-length axis of the cylinder.- Throws:
java.lang.IllegalArgumentException
- if the radius is zero or the top or bottom point is null or they are coincident.
-
-
Method Detail
-
getAxisUnitDirection
public Vec4 getAxisUnitDirection()
Returns the unit-length axis of this cylinder.- Returns:
- the unit-length axis of this cylinder.
-
getBottomCenter
public Vec4 getBottomCenter()
Returns the this cylinder's bottom-center point.- Returns:
- this cylinder's bottom-center point.
-
getTopCenter
public Vec4 getTopCenter()
Returns the this cylinder's top-center point.- Returns:
- this cylinder's top-center point.
-
getCylinderRadius
public double getCylinderRadius()
Returns this cylinder's radius.- Returns:
- this cylinder's radius.
-
getCylinderHeight
public double getCylinderHeight()
Returns this cylinder's height.- Returns:
- this cylinder's height.
-
getCenter
public Vec4 getCenter()
Return this cylinder's center point.
-
getDiameter
public double getDiameter()
Returns the extent's diameter. The computation of the diameter depends on the implementing class. See the documentation for the individual classes to determine how they compute a diameter.- Specified by:
getDiameter
in interfaceExtent
- Returns:
- the extent's diameter.
-
getRadius
public double getRadius()
Returns the extent's radius. The computation of the radius depends on the implementing class. See the documentation for the individual classes to determine how they compute a radius.
-
getVolume
public double getVolume()
Return this cylinder's volume.- Returns:
- this cylinder's volume.
-
computeBoundingCylinder
public static Cylinder computeBoundingCylinder(java.lang.Iterable<? extends Vec4> points)
Compute a bounding cylinder for a collection of points.- Parameters:
points
- the points to compute a bounding cylinder for.- Returns:
- a cylinder bounding all the points. The axis of the cylinder is the longest principal axis of the
collection. (See
WWMath.computePrincipalAxes(Iterable)
. - Throws:
java.lang.IllegalArgumentException
- if the point list is null or empty.- See Also:
computeVerticalBoundingCylinder(gov.nasa.worldwind.globes.Globe, double, Sector)
-
intersect
public Intersection[] intersect(Line line)
Computes the intersections of this extent withline
. The returned array may be either null or of zero length if no intersections are discovered. It does not contain null elements. Tangential intersections are marked as such.line
is considered to have infinite length in both directions.
-
intersects
public boolean intersects(Line line)
Determines whether or notline
intersects thisExtent
. This method may be faster than checking the size of the array returned byintersect(Line)
. Implementing methods must ensure that this method returns true if and only ifintersect(Line)
returns a non-null array containing at least one element.- Specified by:
intersects
in interfaceExtent
- Parameters:
line
- theLine
with which to test for intersection.- Returns:
- true if an intersection is found, false otherwise.
-
intcyl
protected boolean intcyl(Vec4 raybase, Vec4 raycos, Vec4 base, Vec4 axis, double radius, double[] tVals)
-
clipcyl
protected boolean clipcyl(Vec4 raybase, Vec4 raycos, Vec4 bot, Vec4 top, Vec4 axis, double[] tVals)
-
intersects
protected double intersects(Plane plane, double effectiveRadius)
-
getEffectiveRadius
public double getEffectiveRadius(Plane plane)
Computes the effective radius of the extent relative to a specified plane.- Specified by:
getEffectiveRadius
in interfaceExtent
- Parameters:
plane
- the plane.- Returns:
- the effective radius, or 0 if the plane is null.
-
intersects
public boolean intersects(Plane plane)
Calculate whether or not thisExtent
is intersected byplane
.- Specified by:
intersects
in interfaceExtent
- Parameters:
plane
- thePlane
with which to test for intersection.- Returns:
- true if
plane
is found to intersect thisExtent
.
-
intersects
public boolean intersects(Frustum frustum)
Determines whether or not thisExtent
intersectsfrustum
. Returns true if any part of these two objects intersect, including the case where either object wholly contains the other, false otherwise.- Specified by:
intersects
in interfaceExtent
- Parameters:
frustum
- theFrustum
with which to test for intersection.- Returns:
- true if there is an intersection, false otherwise.
-
getProjectedArea
public double getProjectedArea(View view)
Computes the area in square pixels of thisExtent
after it is projected into the specifiedview's
viewport. The returned value is the screen area that thisExtent
covers in the infinite plane defined by theview's
viewport. This area is not limited to the size of theview's
viewport, and portions of thisExtent
are not clipped by theview's
frustum.This returns
Double.POSITIVE_INFINITY
if theview's
eye point is inside thisExtent
, or if any portion of thisExtent
is behind the eye point. In either case, thisExtent
has no finite projection on theview
.- Specified by:
getProjectedArea
in interfaceExtent
- Parameters:
view
- theView
for which to compute a projected screen area.- Returns:
- the projected screen area of this
Extent
in square pixels, orDouble.POSITIVE_INFINITY
if theview's
eye point is inside thisExtent
or part of thisExtent
is behind theview's
eye point.
-
computeVerticalBoundingCylinder
public static Cylinder computeVerticalBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector)
Returns a cylinder that minimally surrounds the specified minimum and maximum elevations in the sector at a specified vertical exaggeration, and is oriented such that the cylinder axis is perpendicular to the globe's surface.- Parameters:
globe
- The globe associated with the sector.verticalExaggeration
- the vertical exaggeration to apply to the minimum and maximum elevations when computing the cylinder.sector
- the sector to return the bounding cylinder for.- Returns:
- The minimal bounding cylinder in Cartesian coordinates.
- Throws:
java.lang.IllegalArgumentException
- ifsector
is null- See Also:
computeBoundingCylinder(Iterable)
-
computeVerticalBoundingCylinder
public static Cylinder computeVerticalBoundingCylinder(Globe globe, double verticalExaggeration, Sector sector, double minElevation, double maxElevation)
Returns a cylinder that minimally surrounds the specified minimum and maximum elevations in the sector at a specified vertical exaggeration, and is oriented such that the cylinder axis is perpendicular to the globe's surface.- Parameters:
globe
- The globe associated with the sector.verticalExaggeration
- the vertical exaggeration to apply to the minimum and maximum elevations when computing the cylinder.sector
- the sector to return the bounding cylinder for.minElevation
- the minimum elevation of the bounding cylinder.maxElevation
- the maximum elevation of the bounding cylinder.- Returns:
- The minimal bounding cylinder in Cartesian coordinates.
- Throws:
java.lang.IllegalArgumentException
- ifsector
is null- See Also:
computeBoundingCylinder(Iterable)
-
computeVerticalBoundsFromSectorLatitudeRange
protected static Cylinder computeVerticalBoundsFromSectorLatitudeRange(Globe globe, Sector sector, double minHeight, double maxHeight)
Compute the Cylinder that surrounds the equator, and has height defined by the sector's minumum and maximum latitudes (including maxHeight).- Parameters:
globe
- The globe associated with the sector.sector
- the sector to return the bounding cylinder for.minHeight
- the minimum height to include in the bounding cylinder.maxHeight
- the maximum height to include in the bounding cylinder.- Returns:
- the minimal bounding cylinder in Cartesianl coordinates.
- Throws:
java.lang.IllegalArgumentException
- ifsector
is null
-
computeVerticalBoundsFromSectorQuadrilateral
protected static Cylinder computeVerticalBoundsFromSectorQuadrilateral(Globe globe, Sector sector, double minHeight, double maxHeight)
Returns a cylinder that minimally surrounds the specified height range in the sector.- Parameters:
globe
- The globe associated with the sector.sector
- the sector to return the bounding cylinder for.minHeight
- the minimum height to include in the bounding cylinder.maxHeight
- the maximum height to include in the bounding cylinder.- Returns:
- The minimal bounding cylinder in Cartesian coordinates.
- Throws:
java.lang.IllegalArgumentException
- ifsector
is null
-
computeVerticalBoundsFromSectorVertices
protected static Cylinder computeVerticalBoundsFromSectorVertices(Globe globe, Sector sector, double minHeight, double maxHeight)
Returns a cylinder that surrounds the specified height range in the zero-area sector. The returned cylinder won't be as tight a fit ascomputeBoundsFromSectorQuadrilateral
.- Parameters:
globe
- The globe associated with the sector.sector
- the sector to return the bounding cylinder for.minHeight
- the minimum height to include in the bounding cylinder.maxHeight
- the maximum height to include in the bounding cylinder.- Returns:
- The minimal bounding cylinder in Cartesian coordinates.
- Throws:
java.lang.IllegalArgumentException
- ifsector
is null
-
render
public void render(DrawContext dc)
Display the cylinder.- Specified by:
render
in interfaceRenderable
- Parameters:
dc
- the current draw context.- Throws:
java.lang.IllegalArgumentException
- if the draw context is null.- See Also:
DrawContext
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-