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.Cylinders are immutable.
-
-
Field Summary
Fields Modifier and Type Field Description protected Vec4axisUnitDirectionprotected Vec4bottomCenterprotected doublecylinderHeightprotected doublecylinderRadiusprotected Vec4topCenter
-
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 booleanclipcyl(Vec4 raybase, Vec4 raycos, Vec4 bot, Vec4 top, Vec4 axis, double[] tVals)static CylindercomputeBoundingCylinder(java.lang.Iterable<? extends Vec4> points)Compute a bounding cylinder for a collection of points.static CylindercomputeVerticalBoundingCylinder(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 CylindercomputeVerticalBoundingCylinder(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 CylindercomputeVerticalBoundsFromSectorLatitudeRange(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 CylindercomputeVerticalBoundsFromSectorQuadrilateral(Globe globe, Sector sector, double minHeight, double maxHeight)Returns a cylinder that minimally surrounds the specified height range in the sector.protected static CylindercomputeVerticalBoundsFromSectorVertices(Globe globe, Sector sector, double minHeight, double maxHeight)Returns a cylinder that surrounds the specified height range in the zero-area sector.booleanequals(java.lang.Object o)Vec4getAxisUnitDirection()Returns the unit-length axis of this cylinder.Vec4getBottomCenter()Returns the this cylinder's bottom-center point.Vec4getCenter()Return this cylinder's center point.doublegetCylinderHeight()Returns this cylinder's height.doublegetCylinderRadius()Returns this cylinder's radius.doublegetDiameter()Returns the extent's diameter.doublegetEffectiveRadius(Plane plane)Computes the effective radius of the extent relative to a specified plane.doublegetProjectedArea(View view)Computes the area in square pixels of thisExtentafter it is projected into the specifiedview'sviewport.doublegetRadius()Returns the extent's radius.Vec4getTopCenter()Returns the this cylinder's top-center point.doublegetVolume()Return this cylinder's volume.inthashCode()protected booleanintcyl(Vec4 raybase, Vec4 raycos, Vec4 base, Vec4 axis, double radius, double[] tVals)Intersection[]intersect(Line line)Computes the intersections of this extent withline.booleanintersects(Frustum frustum)Determines whether or not thisExtentintersectsfrustum.booleanintersects(Line line)Determines whether or notlineintersects thisExtent.booleanintersects(Plane plane)Calculate whether or not thisExtentis intersected byplane.protected doubleintersects(Plane plane, double effectiveRadius)protected doubleintersectsAt(Plane plane, double effectiveRadius, Vec4[] endpoints)voidrender(DrawContext dc)Display the cylinder.java.lang.StringtoString()
-
-
-
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:
getDiameterin 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.lineis considered to have infinite length in both directions.
-
intersects
public boolean intersects(Line line)
Determines whether or notlineintersects 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:
intersectsin interfaceExtent- Parameters:
line- theLinewith 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:
getEffectiveRadiusin 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 thisExtentis intersected byplane.- Specified by:
intersectsin interfaceExtent- Parameters:
plane- thePlanewith which to test for intersection.- Returns:
- true if
planeis found to intersect thisExtent.
-
intersects
public boolean intersects(Frustum frustum)
Determines whether or not thisExtentintersectsfrustum. Returns true if any part of these two objects intersect, including the case where either object wholly contains the other, false otherwise.- Specified by:
intersectsin interfaceExtent- Parameters:
frustum- theFrustumwith 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 thisExtentafter it is projected into the specifiedview'sviewport. The returned value is the screen area that thisExtentcovers in the infinite plane defined by theview'sviewport. This area is not limited to the size of theview'sviewport, and portions of thisExtentare not clipped by theview'sfrustum.This returns
Double.POSITIVE_INFINITYif theview'seye point is inside thisExtent, or if any portion of thisExtentis behind the eye point. In either case, thisExtenthas no finite projection on theview.- Specified by:
getProjectedAreain interfaceExtent- Parameters:
view- theViewfor which to compute a projected screen area.- Returns:
- the projected screen area of this
Extentin square pixels, orDouble.POSITIVE_INFINITYif theview'seye point is inside thisExtentor part of thisExtentis behind theview'seye 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- ifsectoris 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- ifsectoris 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- ifsectoris 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- ifsectoris 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- ifsectoris null
-
render
public void render(DrawContext dc)
Display the cylinder.- Specified by:
renderin 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:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-