NASA World Wind
gov.nasa.worldwind.geom

## Class Cylinder

• All Implemented Interfaces:
Extent, Renderable

```public class Cylinder
extends 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 and Description
`protected Vec4` `axisUnitDirection`
`protected Vec4` `bottomCenter`
`protected double` `cylinderHeight`
`protected double` `cylinderRadius`
`protected Vec4` `topCenter`
• ### Constructor Summary

Constructors
Constructor and 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
Modifier and Type Method and Description
`protected boolean` ```clipcyl(Vec4 raybase, Vec4 raycos, Vec4 bot, Vec4 top, Vec4 axis, double[] tVals)```
`static Cylinder` `computeBoundingCylinder(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(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()`
`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 this `Extent` after it is projected into the specified `view's` viewport.
`double` `getRadius()`
`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 with `line`.
`boolean` `intersects(Frustum frustum)`
Determines whether or not this `Extent` intersects `frustum`.
`boolean` `intersects(Line line)`
Determines whether or not `line` intersects this `Extent`.
`boolean` `intersects(Plane plane)`
Calculate whether or not this `Extent` is intersected by `plane`.
`protected double` ```intersects(Plane plane, double effectiveRadius)```
`protected double` ```intersectsAt(Plane plane, double effectiveRadius, Vec4[] endpoints)```
`void` `render(DrawContext dc)`
Display the cylinder.
`String` `toString()`
• ### Methods inherited from class java.lang.Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### axisUnitDirection

`protected final Vec4 axisUnitDirection`
• #### bottomCenter

`protected final Vec4 bottomCenter`
• #### cylinderHeight

`protected final double cylinderHeight`

`protected final double cylinderRadius`
• #### topCenter

`protected final Vec4 topCenter`
• ### Constructor Detail

• #### Cylinder

```public Cylinder(Vec4 bottomCenter,
Vec4 topCenter,
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:
`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,
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:
`IllegalArgumentException` - if the radius is zero or the top or bottom point is null or they are coincident.
• ### Method Detail

• #### clipcyl

```protected boolean clipcyl(Vec4 raybase,
Vec4 raycos,
Vec4 bot,
Vec4 top,
Vec4 axis,
double[] tVals)```
• #### 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:
`IllegalArgumentException` - if `sector` is null
`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:
`IllegalArgumentException` - if `sector` is null
`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:
`IllegalArgumentException` - if `sector` is null

```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:
`IllegalArgumentException` - if `sector` 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 as `computeBoundsFromSectorQuadrilateral`.
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:
`IllegalArgumentException` - if `sector` is null
• #### equals

`public boolean equals(Object o)`
Overrides:
`equals` in class `Object`
• #### 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.
• #### getCenter

`public Vec4 getCenter()`
Return this cylinder's center point.
Specified by:
`getCenter` in interface `Extent`
Returns:
this cylinder's center point.
• #### getCylinderHeight

`public double getCylinderHeight()`
Returns this cylinder's height.
Returns:
this cylinder's height.

`public double getCylinderRadius()`
Returns:
• #### 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 interface `Extent`
Returns:
the extent's diameter.

`public double getEffectiveRadius(Plane plane)`
Computes the effective radius of the extent relative to a specified plane.
Specified by:
`getEffectiveRadius` in interface `Extent`
Parameters:
`plane` - the plane.
Returns:
the effective radius, or 0 if the plane is null.
• #### getProjectedArea

`public double getProjectedArea(View view)`
Computes the area in square pixels of this `Extent` after it is projected into the specified `view's` viewport. The returned value is the screen area that this `Extent` covers in the infinite plane defined by the `view's` viewport. This area is not limited to the size of the `view's` viewport, and portions of this `Extent` are not clipped by the `view's` frustum.

This returns `Double.POSITIVE_INFINITY` if the `view's` eye point is inside this `Extent`, or if any portion of this `Extent` is behind the eye point. In either case, this `Extent` has no finite projection on the `view`.

Specified by:
`getProjectedArea` in interface `Extent`
Parameters:
`view` - the `View` for which to compute a projected screen area.
Returns:
the projected screen area of this `Extent` in square pixels, or `Double.POSITIVE_INFINITY` if the `view's` eye point is inside this `Extent` or part of this `Extent` is behind the `view's` eye point.

`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.
Specified by:
`getRadius` in interface `Extent`
Returns:
• #### getTopCenter

`public Vec4 getTopCenter()`
Returns the this cylinder's top-center point.
Returns:
this cylinder's top-center point.
• #### getVolume

`public double getVolume()`
Return this cylinder's volume.
Returns:
this cylinder's volume.
• #### hashCode

`public int hashCode()`
Overrides:
`hashCode` in class `Object`
• #### intcyl

```protected boolean intcyl(Vec4 raybase,
Vec4 raycos,
Vec4 base,
Vec4 axis,
double[] tVals)```
• #### intersect

`public Intersection[] intersect(Line line)`
Computes the intersections of this extent with `line`. 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.
Specified by:
`intersect` in interface `Extent`
Parameters:
`line` - the `Line` with which to intersect this `Extent`.
Returns:
an array of intersections representing all the points where `line` enters or leave this `Extent`.
• #### intersects

`public boolean intersects(Frustum frustum)`
Determines whether or not this `Extent` intersects `frustum`. 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 interface `Extent`
Parameters:
`frustum` - the `Frustum` with which to test for intersection.
Returns:
true if there is an intersection, false otherwise.
• #### intersects

`public boolean intersects(Line line)`
Determines whether or not `line` intersects this `Extent`. This method may be faster than checking the size of the array returned by `intersect(Line)`. Implementing methods must ensure that this method returns true if and only if `intersect(Line)` returns a non-null array containing at least one element.
Specified by:
`intersects` in interface `Extent`
Parameters:
`line` - the `Line` with which to test for intersection.
Returns:
true if an intersection is found, false otherwise.
• #### intersects

`public boolean intersects(Plane plane)`
Calculate whether or not this `Extent` is intersected by `plane`.
Specified by:
`intersects` in interface `Extent`
Parameters:
`plane` - the `Plane` with which to test for intersection.
Returns:
true if `plane` is found to intersect this `Extent`.
• #### intersects

```protected double intersects(Plane plane,
• #### intersectsAt

```protected double intersectsAt(Plane plane,
Vec4[] endpoints)```
• #### render

`public void render(DrawContext dc)`
Display the cylinder.
Specified by:
`render` in interface `Renderable`
Parameters:
`dc` - the current draw context.
Throws:
`IllegalArgumentException` - if the draw context is null.
`DrawContext`
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`