# Rectangle

#### new Cesium.Rectangle(west, south, east, north)
engine/Source/Core/Rectangle.js 21

A two dimensional region specified as longitude and latitude coordinates.

Name | Type | Default | Description
--- | --- | --- | ---
`west` | number | `0.0` | optional The westernmost longitude, in radians, in the range [-Pi, Pi].
`south` | number | `0.0` | optional The southernmost latitude, in radians, in the range [-Pi/2, Pi/2].
`east` | number | `0.0` | optional The easternmost longitude, in radians, in the range [-Pi, Pi].
`north` | number | `0.0` | optional The northernmost latitude, in radians, in the range [-Pi/2, Pi/2].

##### See:

- Packable

### Members

#### static constant Cesium.Rectangle.MAX_VALUE : Rectangle
engine/Source/Core/Rectangle.js 974

The largest possible rectangle.

#### static Cesium.Rectangle.packedLength : number
engine/Source/Core/Rectangle.js 85

The number of elements used to pack the object into an array.

#### east : number
engine/Source/Core/Rectangle.js 44

The easternmost longitude in radians in the range [-Pi, Pi].

Default Value: `0.0`

#### readonly height : number
engine/Source/Core/Rectangle.js 74

Gets the height of the rectangle in radians.

#### north : number
engine/Source/Core/Rectangle.js 52

The northernmost latitude in radians in the range [-Pi/2, Pi/2].

Default Value: `0.0`

#### south : number
engine/Source/Core/Rectangle.js 36

The southernmost latitude in radians in the range [-Pi/2, Pi/2].

Default Value: `0.0`

#### west : number
engine/Source/Core/Rectangle.js 28

The westernmost longitude in radians in the range [-Pi, Pi].

Default Value: `0.0`

#### readonly width : number
engine/Source/Core/Rectangle.js 62

Gets the width of the rectangle in radians.

### Methods

#### static Cesium.Rectangle.center(rectangle, result) → Cartographic
engine/Source/Core/Rectangle.js 577

Computes the center of a rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle for which to find the center
`result` | Cartographic | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartographic instance if none was provided.

#### static Cesium.Rectangle.clone(rectangle, result) → Rectangle
engine/Source/Core/Rectangle.js 347

Duplicates a Rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle to clone.
`result` | Rectangle | optional The object onto which to store the result, or undefined if a new instance should be created.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided. (Returns undefined if rectangle is undefined)

#### static Cesium.Rectangle.computeHeight(rectangle) → number
engine/Source/Core/Rectangle.js 160

Computes the height of a rectangle in radians.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle to compute the height of.

##### Returns:

The height.

#### static Cesium.Rectangle.computeWidth(rectangle) → number
engine/Source/Core/Rectangle.js 143

Computes the width of a rectangle in radians.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle to compute the width of.

##### Returns:

The width.

#### static Cesium.Rectangle.contains(rectangle, cartographic) → boolean
engine/Source/Core/Rectangle.js 791

Returns true if the cartographic is on or inside the rectangle, false otherwise.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle
`cartographic` | Cartographic | The cartographic to test.

##### Returns:

true if the provided cartographic is inside the rectangle, false otherwise.

#### static Cesium.Rectangle.equals(left, right) → boolean
engine/Source/Core/Rectangle.js 421

Compares the provided rectangles and returns `true` if they are equal, `false` otherwise.

Name | Type | Description
--- | --- | ---
`left` | Rectangle | optional The first Rectangle.
`right` | Rectangle | optional The second Rectangle.

##### Returns:

`true` if left and right are equal; otherwise `false`.

#### static Cesium.Rectangle.equalsEpsilon(left, right, absoluteEpsilon) → boolean
engine/Source/Core/Rectangle.js 378

Compares the provided Rectangles componentwise and returns `true` if they pass an absolute or relative tolerance test, `false` otherwise.

Name | Type | Default | Description
--- | --- | --- | ---
`left` | Rectangle |  | optional The first Rectangle.
`right` | Rectangle |  | optional The second Rectangle.
`absoluteEpsilon` | number | `0` | optional The absolute epsilon tolerance to use for equality testing.

##### Returns:

`true` if left and right are within the provided epsilon, `false` otherwise.

#### static Cesium.Rectangle.expand(rectangle, cartographic, result) → Rectangle
engine/Source/Core/Rectangle.js 766

Computes a rectangle by enlarging the provided rectangle until it contains the provided cartographic.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | A rectangle to expand.
`cartographic` | Cartographic | A cartographic to enclose in a rectangle.
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Rectangle instance if one was not provided.

#### static Cesium.Rectangle.fromCartesianArray(cartesians, ellipsoid, result) → Rectangle
engine/Source/Core/Rectangle.js 289

Creates the smallest possible Rectangle that encloses all positions in the provided array.

Name | Type | Default | Description
--- | --- | --- | ---
`cartesians` | Array.<Cartesian3> |  | The list of Cartesian instances.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid the cartesians are on.
`result` | Rectangle |  | optional The object onto which to store the result, or undefined if a new instance should be created.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

#### static Cesium.Rectangle.fromCartographicArray(cartographics, result) → Rectangle
engine/Source/Core/Rectangle.js 231

Creates the smallest possible Rectangle that encloses all positions in the provided array.

Name | Type | Description
--- | --- | ---
`cartographics` | Array.<Cartographic> | The list of Cartographic instances.
`result` | Rectangle | optional The object onto which to store the result, or undefined if a new instance should be created.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

#### static Cesium.Rectangle.fromDegrees(west, south, east, north, result) → Rectangle
engine/Source/Core/Rectangle.js 180

Creates a rectangle given the boundary longitude and latitude in degrees.

Name | Type | Default | Description
--- | --- | --- | ---
`west` | number | `0.0` | optional The westernmost longitude in degrees in the range [-180.0, 180.0].
`south` | number | `0.0` | optional The southernmost latitude in degrees in the range [-90.0, 90.0].
`east` | number | `0.0` | optional The easternmost longitude in degrees in the range [-180.0, 180.0].
`north` | number | `0.0` | optional The northernmost latitude in degrees in the range [-90.0, 90.0].
`result` | Rectangle |  | optional The object onto which to store the result, or undefined if a new instance should be created.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

##### Example:

    const rectangle = Cesium.Rectangle.fromDegrees(0.0, 20.0, 10.0, 30.0);

#### static Cesium.Rectangle.fromRadians(west, south, east, north, result) → Rectangle
engine/Source/Core/Rectangle.js 211

Creates a rectangle given the boundary longitude and latitude in radians.

Name | Type | Default | Description
--- | --- | --- | ---
`west` | number | `0.0` | optional The westernmost longitude in radians in the range [-Math.PI, Math.PI].
`south` | number | `0.0` | optional The southernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
`east` | number | `0.0` | optional The easternmost longitude in radians in the range [-Math.PI, Math.PI].
`north` | number | `0.0` | optional The northernmost latitude in radians in the range [-Math.PI/2, Math.PI/2].
`result` | Rectangle |  | optional The object onto which to store the result, or undefined if a new instance should be created.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

##### Example:

    const rectangle = Cesium.Rectangle.fromRadians(0.0, Math.PI/4, Math.PI/8, 3*Math.PI/4);

#### static Cesium.Rectangle.intersection(rectangle, otherRectangle, result) → Rectangle|undefined
engine/Source/Core/Rectangle.js 614

Computes the intersection of two rectangles. This function assumes that the rectangle's coordinates are latitude and longitude in radians and produces a correct intersection, taking into account the fact that the same angle can be represented with multiple values as well as the wrapping of longitude at the anti-meridian. For a simple intersection that ignores these factors and can be used with projected coordinates, see `Rectangle.simpleIntersection`.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | On rectangle to find an intersection
`otherRectangle` | Rectangle | Another rectangle to find an intersection
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.

#### static Cesium.Rectangle.northeast(rectangle, result) → Cartographic
engine/Source/Core/Rectangle.js 535

Computes the northeast corner of a rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle for which to find the corner
`result` | Cartographic | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartographic instance if none was provided.

#### static Cesium.Rectangle.northwest(rectangle, result) → Cartographic
engine/Source/Core/Rectangle.js 514

Computes the northwest corner of a rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle for which to find the corner
`result` | Cartographic | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartographic instance if none was provided.

#### static Cesium.Rectangle.pack(value, array, startingIndex) → Array.<number>
engine/Source/Core/Rectangle.js 96

Stores the provided instance into the provided array.

Name | Type | Default | Description
--- | --- | --- | ---
`value` | Rectangle |  | The value to pack.
`array` | Array.<number> |  | The array to pack into.
`startingIndex` | number | `0` | optional The index into the array at which to start packing the elements.

##### Returns:

The array that was packed into

#### static Cesium.Rectangle.simpleIntersection(rectangle, otherRectangle, result) → Rectangle|undefined
engine/Source/Core/Rectangle.js 681

Computes a simple intersection of two rectangles. Unlike `Rectangle.intersection`, this function does not attempt to put the angular coordinates into a consistent range or to account for crossing the anti-meridian. As such, it can be used for rectangles where the coordinates are not simply latitude and longitude (i.e. projected coordinates).

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | On rectangle to find an intersection
`otherRectangle` | Rectangle | Another rectangle to find an intersection
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter, a new Rectangle instance if none was provided or undefined if there is no intersection.

#### static Cesium.Rectangle.southeast(rectangle, result) → Cartographic
engine/Source/Core/Rectangle.js 556

Computes the southeast corner of a rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle for which to find the corner
`result` | Cartographic | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartographic instance if none was provided.

#### static Cesium.Rectangle.southwest(rectangle, result) → Cartographic
engine/Source/Core/Rectangle.js 493

Computes the southwest corner of a rectangle.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle for which to find the corner
`result` | Cartographic | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Cartographic instance if none was provided.

#### static Cesium.Rectangle.subsample(rectangle, ellipsoid, surfaceHeight, result) → Array.<Cartesian3>
engine/Source/Core/Rectangle.js 831

Samples a rectangle so that it includes a list of Cartesian points suitable for passing to `BoundingSphere#fromPoints`. Sampling is necessary to account for rectangles that cover the poles or cross the equator.

Name | Type | Default | Description
--- | --- | --- | ---
`rectangle` | Rectangle |  | The rectangle to subsample.
`ellipsoid` | Ellipsoid | `Ellipsoid.WGS84` | optional The ellipsoid to use.
`surfaceHeight` | number | `0.0` | optional The height of the rectangle above the ellipsoid.
`result` | Array.<Cartesian3> |  | optional The array of Cartesians onto which to store the result.

##### Returns:

The modified result parameter or a new Array of Cartesians instances if none was provided.

#### static Cesium.Rectangle.subsection(rectangle, westLerp, southLerp, eastLerp, northLerp, result) → Rectangle
engine/Source/Core/Rectangle.js 908

Computes a subsection of a rectangle from normalized coordinates in the range [0.0, 1.0].

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle to subsection.
`westLerp` | number | The west interpolation factor in the range [0.0, 1.0]. Must be less than or equal to eastLerp.
`southLerp` | number | The south interpolation factor in the range [0.0, 1.0]. Must be less than or equal to northLerp.
`eastLerp` | number | The east interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to westLerp.
`northLerp` | number | The north interpolation factor in the range [0.0, 1.0]. Must be greater than or equal to southLerp.
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

#### static Cesium.Rectangle.union(rectangle, otherRectangle, result) → Rectangle
engine/Source/Core/Rectangle.js 715

Computes a rectangle that is the union of two rectangles.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | A rectangle to enclose in rectangle.
`otherRectangle` | Rectangle | A rectangle to enclose in a rectangle.
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

#### static Cesium.Rectangle.unpack(array, startingIndex, result) → Rectangle
engine/Source/Core/Rectangle.js 120

Retrieves an instance from a packed array.

Name | Type | Default | Description
--- | --- | --- | ---
`array` | Array.<number> |  | The packed array.
`startingIndex` | number | `0` | optional The starting index of the element to be unpacked.
`result` | Rectangle |  | optional The object into which to store the result.

##### Returns:

The modified result parameter or a new Rectangle instance if one was not provided.

#### static Cesium.Rectangle.validate(rectangle)
engine/Source/Core/Rectangle.js 456

Checks a Rectangle's properties and throws if they are not in valid ranges.

Name | Type | Description
--- | --- | ---
`rectangle` | Rectangle | The rectangle to validate

##### Throws:

- DeveloperError : `north` must be in the interval [`-Pi/2`, `Pi/2`].
- DeveloperError : `south` must be in the interval [`-Pi/2`, `Pi/2`].
- DeveloperError : `east` must be in the interval [`-Pi`, `Pi`].
- DeveloperError : `west` must be in the interval [`-Pi`, `Pi`].

#### clone(result) → Rectangle
engine/Source/Core/Rectangle.js 398

Duplicates this Rectangle.

Name | Type | Description
--- | --- | ---
`result` | Rectangle | optional The object onto which to store the result.

##### Returns:

The modified result parameter or a new Rectangle instance if none was provided.

#### equals(other) → boolean
engine/Source/Core/Rectangle.js 409

Compares the provided Rectangle with this Rectangle componentwise and returns `true` if they are equal, `false` otherwise.

Name | Type | Description
--- | --- | ---
`other` | Rectangle | optional The Rectangle to compare.

##### Returns:

`true` if the Rectangles are equal, `false` otherwise.

#### equalsEpsilon(other, epsilon) → boolean
engine/Source/Core/Rectangle.js 442

Compares the provided Rectangle with this Rectangle componentwise and returns `true` if they are within the provided epsilon, `false` otherwise.

Name | Type | Default | Description
--- | --- | --- | ---
`other` | Rectangle |  | optional The Rectangle to compare.
`epsilon` | number | `0` | optional The epsilon to use for equality testing.

##### Returns:

`true` if the Rectangles are within the provided epsilon, `false` otherwise.

Need help? The fastest way to get answers is from the community and team on the Cesium Forum.