Struct s2::cap::Cap[][src]

pub struct Cap {
    pub center: Point,
    pub radius: ChordAngle,
}

Cap represents a disc-shaped region defined by a center and radius. Technically this shape is called a "spherical cap" (rather than disc) because it is not planar; the cap represents a portion of the sphere that has been cut off by a plane. The boundary of the cap is the circle defined by the intersection of the sphere and the plane. For containment purposes, the cap is a closed set, i.e. it contains its boundary.

For the most part, you can use a spherical cap wherever you would use a disc in planar geometry. The radius of the cap is measured along the surface of the sphere (rather than the straight-line distance through the interior). Thus a cap of radius π/2 is a hemisphere, and a cap of radius π covers the entire sphere.

The center is a point on the surface of the unit sphere. (Hence the need for it to be of unit length.)

A cap can also be defined by its center point and height. The height is the distance from the center point to the cutoff plane. There is also support for "empty" and "full" caps, which contain no points and all points respectively.

Here are some useful relationships between the cap height (h), the cap radius (r), the maximum chord length from the cap's center (d), and the radius of cap's base (a).

This example is not tested
    h = 1 - cos(r)
      = 2 * sin^2(r/2)
  d^2 = 2 * h
      = a^2 + h^2

The zero value of Cap is an invalid cap. Use EmptyCap to get a valid empty cap.

Fields

Methods

impl Cap
[src]

from_center_angle constructs a cap with the given center and angle.

from_center_chordangle constructs a cap where the angle is expressed as an s1.ChordAngle. This constructor is more efficient than using an s1.Angle.

from_center_height constructs a cap with the given center and height. A negative height yields an empty cap; a height of 2 or more yields a full cap. The center should be unit length.

from_center_area constructs a cap with the given center and surface area. Note that the area can also be interpreted as the solid angle subtended by the cap (because the sphere has unit radius). A negative area yields an empty cap; an area of 4*π or more yields a full cap.

empty returns a cap that contains no points.

full returns a cap that contains all points.

is_valid reports whether the Cap is considered valid.

is_empty reports whether the cap is empty, i.e. it contains no points.

is_full reports whether the cap is empty, i.e. it contains no points.

center returns the cap's center point.

height returns the height of the cap. This is the distance from the center point to the cutoff plane.

radius returns the cap radius as an Angle. (Note that the cap angle is stored internally as a ChordAngle, so this method requires a trigonometric operation and may yield a slightly different result than the value passed to Cap::from_center_angle).

area returns the surface area of the Cap on the unit sphere.

contains reports whether this cap contains the other.

intersects reports whether this cap intersects the other cap. i.e. whether they have any points in common.

interior_intersects reports whether this caps interior intersects the other cap.

contains_point reports whether this cap contains the point.

interior_contains_point reports whether the point is within the interior of this cap.

complement returns the complement of the interior of the cap. A cap and its complement have the same boundary but do not share any interior points. The complement operator is not a bijection because the complement of a singleton cap (containing a single point) is the same as the complement of an empty cap.

approx_eq reports whether this cap is equal to the other cap within the given tolerance.

expanded returns a new cap expanded by the given angle. If the cap is empty, it returns an empty cap.

impl Cap
[src]

Centroid returns the true centroid of the cap multiplied by its surface area The result lies on the ray from the origin through the cap's center, but it is not unit length. Note that if you just want the "surface centroid", i.e. the normalized result, then it is simpler to call Center.

The reason for multiplying the result by the cap area is to make it easier to compute the centroid of more complicated shapes. The centroid of a union of disjoint regions can be computed simply by adding their Centroid() results. Caveat: for caps that contain a single point (i.e., zero radius), this method always returns the origin (0, 0, 0). This is because shapes with no area don't affect the centroid of a union whose total area is positive.

union returns the smallest cap which encloses this cap and other.

Trait Implementations

impl Clone for Cap
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for Cap
[src]

Formats the value using the given formatter. Read more

impl<'a> From<&'a Point> for Cap
[src]

constructs a cap containing a single point.

impl Region for Cap
[src]

cap_bound returns a bounding spherical cap. This is not guaranteed to be exact.

rect_bound returns a bounding latitude-longitude rectangle. The bounds are not guaranteed to be tight.

contains_cell reports whether the cap contains the given cell.

intersects_cell reports whether the cap intersects the cell.

impl PartialEq for Cap
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<'a> Add<&'a Point> for Cap
[src]

The resulting type after applying the + operator.

increases the cap if necessary to include the given point. If this cap is empty, then the center is set to the point with a zero height. p must be unit-length.

impl<'a> Add<&'a Cap> for Cap
[src]

The resulting type after applying the + operator.

increases the cap height if necessary to include the other cap. If this cap is empty, it is set to the other cap.

impl Add<Cap> for Cap
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl Display for Cap
[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for Cap

impl Sync for Cap