Spherical.R2.Rectangle

Represents a closed axis-aligned rectangle in ℝ².

Describes every point in two-dimensional space by means of two coordinates.

Source

Summary

add_point(rectangle, point)

Expands the rectangle to include the given point

add_rectangle(first, second)

Expands the first rectangle to include the second

approx_equals(first, second)

Returns true if the x- and y-intervals of the two rectangles are the same up to the given tolerance

center(rectangle)

Returns the center of the rectangle in ℝ²

clamp_point(rectangle, point)

Returns the closest point in the rectangle to the given point

contains?(first, second)

Checks whether the first rectangle contains the second

contains_point?(rectangle, point)

Checks whether the rectangle contains the given point

expanded(rectangle, margin)

Returns a rectangle that has been expanded in the x-direction by margin.x and in y-direction by margin.y

expanded_by_margin(rectangle, margin)

Returns a rectangle that has been expanded by the amount on all sides by margin

from_center(center, size)

Returns a rectangle with the given center and size

from_points(list1)

Returns a rectangle that contains the given points

interior_contains?(first, second)

Checks whether the interior of the first rectangle contains all of the points of the second (including its boundary)

interior_contains_point?(rectangle, point)

Returns true if the given point is contained in the interior of the rectangle (i.e. the region excluding its boundary)

interior_intersects?(first, second)

Checks whether the interior of the first rectangle intersects any point (including the boundary) of the second

intersection(first, second)

Returns the smallest rectangle containing the intersection of the first and second rectangles

intersects?(first, second)

Checks whether the first rectangle and the second have any points in common

is_empty?(rectangle)

Checks whether the rectangle is empty

is_valid?(rectangle)

Checks whether the rectangle is valid

new()

Returns an empty rectangle

new(x, y)

Returns a rectangle with the given intervals

size(rectangle)

Returns the width and height of this rectangle in (x,y)-space

union(first, second)

Returns the smallest rectangle containing the union of the first and second rectangles

vertices(rectangle)

Returns all four vertices of the rectangle

Types

t :: %Spherical.R2.Rectangle{x: Spherical.R1.Interval.t, y: Spherical.R1.Interval.t}

Functions

add_point(rectangle, point)

Expands the rectangle to include the given point.

The rectangle is expanded by the minimum amount possible.

Source
add_rectangle(first, second)

Expands the first rectangle to include the second.

This is the same as replacing the one rectangle by the union of the two rectangles, but is more efficient.

Source
approx_equals(first, second)

Returns true if the x- and y-intervals of the two rectangles are the same up to the given tolerance.

Source
center(rectangle)

Returns the center of the rectangle in ℝ²

Source
clamp_point(rectangle, point)

Returns the closest point in the rectangle to the given point.

The rectangle must be non-empty.

Source
contains?(first, second)

Checks whether the first rectangle contains the second.

Source
contains_point?(rectangle, point)

Checks whether the rectangle contains the given point.

Rectangles are closed regions, i.e. they contain their boundary.

Source
expanded(rectangle, margin)

Returns a rectangle that has been expanded in the x-direction by margin.x and in y-direction by margin.y.

If either margin is empty, then shrink the interval on the corresponding sides instead. The resulting rectangle may be empty. Any expansion of an empty rectangle remains empty.

Source
expanded_by_margin(rectangle, margin)

Returns a rectangle that has been expanded by the amount on all sides by margin.

Source
from_center(center, size)

Returns a rectangle with the given center and size.

Both dimensions of size must be non-negative.

Source
from_points(list1)

Returns a rectangle that contains the given points.

Source
interior_contains?(first, second)

Checks whether the interior of the first rectangle contains all of the points of the second (including its boundary).

Source
interior_contains_point?(rectangle, point)

Returns true if the given point is contained in the interior of the rectangle (i.e. the region excluding its boundary).

Source
interior_intersects?(first, second)

Checks whether the interior of the first rectangle intersects any point (including the boundary) of the second.

Source
intersection(first, second)

Returns the smallest rectangle containing the intersection of the first and second rectangles.

Source
intersects?(first, second)

Checks whether the first rectangle and the second have any points in common.

Source
is_empty?(rectangle)

Checks whether the rectangle is empty.

Source
is_valid?(rectangle)

Checks whether the rectangle is valid.

This requires the width to be empty if the height is empty.

Source
new()

Returns an empty rectangle.

Source
new(x, y)

Returns a rectangle with the given intervals.

Source
size(rectangle)

Returns the width and height of this rectangle in (x,y)-space.

Empty rectangles have a negative width and height.

Source
union(first, second)

Returns the smallest rectangle containing the union of the first and second rectangles.

Source
vertices(rectangle)

Returns all four vertices of the rectangle.

Vertices are returned in CCW direction starting with the lower left corner.

Source