NRectangle
public struct NRectangle<Vector> : ConstructableRectangleType where Vector : VectorType
extension NRectangle: Equatable where Vector: Equatable, Scalar: Equatable
extension NRectangle: Hashable where Vector: Hashable, Scalar: Hashable
extension NRectangle: Encodable where Vector: Encodable, Scalar: Encodable
extension NRectangle: Decodable where Vector: Decodable, Scalar: Decodable
extension NRectangle: AdditiveRectangleType where Vector: VectorAdditive
extension NRectangle: BoundableType where Vector: VectorAdditive
extension NRectangle: VolumetricType where Vector: VectorAdditive & VectorComparable
extension NRectangle: SelfIntersectableRectangleType where Vector: VectorAdditive & VectorComparable
extension NRectangle: DivisibleRectangleType where Vector: VectorDivisible & VectorComparable
extension NRectangle: ConvexType where Vector: VectorFloatingPoint
extension NRectangle: SignedDistanceMeasurableType where Vector: VectorFloatingPoint
Represents an N-dimensional rectangle with a vector describing its origin and a size vector that describes the span of the rectangle.
-
Convenience for
Vector.Scalar
Declaration
Swift
public typealias Scalar = Vector.Scalar
-
The starting location of this rectangle with the minimal coordinates contained within the rectangle.
Declaration
Swift
public var location: Vector
-
The size of this rectangle, which when added to
location
produce the maximal coordinates contained within this rectangle.Must be
>= Vector.zero
Declaration
Swift
public var size: Vector
-
Initializes a NRectangle with the location + size of a rectangle.
Declaration
Swift
public init(location: Vector, size: Vector)
-
Returns a
RoundNRectangle
which has the same bounds as this rectangle, with the given radius vector describing the dimensions of the corner arcs.Declaration
Swift
@inlinable public func rounded(radius: Vector) -> RoundNRectangle<Vector>
-
Returns a
RoundNRectangle
which has the same bounds as this rectangle, with the given radius value describing the dimensions of the corner arcs.Alias for
rounded(radius: Vector(repeating: radius))
Declaration
Swift
public func rounded(radius: Scalar) -> RoundNRectangle<Vector>
-
Returns an empty rectangle
Declaration
Swift
public static var zero: NRectangle { get }
-
Returns
true
if the size of this rectangle is zero.Declaration
Swift
public var isSizeZero: Bool { get }
-
Minimum point for this rectangle.
When set, the maximal point on the opposite corner is kept fixed.
Declaration
Swift
public var minimum: Vector { get set }
-
Maximum point for this rectangle.
When set, the minimal point on the opposite corner is kept fixed.
Declaration
Swift
public var maximum: Vector { get set }
-
Initializes an empty NRectangle instance.
Declaration
Swift
public init()
-
Initializes a
NRectangle
instance out of the given minimum and maximum coordinates.Precondition
minimum <= maximum
Declaration
Swift
public init(minimum: Vector, maximum: Vector)
-
Returns
true
ifsize >= .zero
.Declaration
Swift
public var isValid: Bool { get }
-
Initializes a NRectangle containing the minimum area capable of containing all supplied points.
If no points are supplied, an empty NRectangle is created instead.
Declaration
Swift
public init(of points: Vector...)
-
Initializes a NRectangle out of a set of points, expanding to the smallest bounding box capable of fitting each point.
Declaration
Swift
@inlinable public init<C>(points: C) where Vector == C.Element, C : Collection
-
Expands the bounding box of this NRectangle to include the given point.
Declaration
Swift
public mutating func expand(toInclude point: Vector)
-
Expands the bounding box of this NRectangle to include the given set of points.
Same as calling
expand(toInclude:)
over each point. If the array is empty, nothing is done.Declaration
Swift
@inlinable public mutating func expand<S: Sequence>( toInclude points: S ) where S.Element == Vector
-
Returns whether a given point is contained within this bounding box.
Points at the perimeter of the N-rectangle (distance to nearest edge == 0) are considered as contained within the N-rectangle.
Declaration
Swift
public func contains(_ point: Vector) -> Bool
-
Returns whether a given NRectangle rests completely inside the boundaries of this NRectangle.
Declaration
Swift
public func contains(_ other: `Self`) -> Bool
-
Returns whether this NRectangle intersects the given NRectangle instance. This check is inclusive, so the edges of the bounding box are considered to intersect the other bounding box’s edges as well.
Declaration
Swift
public func intersects(_ other: `Self`) -> Bool
-
Returns a NRectangle which is the minimum NRectangle that can fit this NRectangle with another given NRectangle.
Declaration
Swift
public func union(_ other: `Self`) -> NRectangle<Vector>
-
Creates a rectangle which is equal to the positive area shared between this rectangle and
other
.If the rectangles do not intersect (i.e. produce a rectangle with < 0 bounds),
nil
is returned, instead.Declaration
Swift
@inlinable public func intersection(_ other: `Self`) -> `Self`?
-
Returns a NRectangle which is the minimum NRectangle that can fit two given Rectangles.
Declaration
Swift
public static func union(_ left: `Self`, _ right: `Self`) -> NRectangle<Vector>
-
Returns an
NRectangle
with location.zero
and size.one
.Declaration
Swift
static var unit: `Self` { get }
-
Returns a NRectangle with the same position as this NRectangle, with its size multiplied by the coordinates of the given vector.
Declaration
Swift
@inlinable func scaledBy(vector: Vector) -> NRectangle<Vector>
-
Subdivides this rectangle into
2 ^ D
(whereD
is the dimensional size ofSelf.Vector
) rectangles that occupy the same area as this rectangle but subdivide it into equally-sized rectangles.The ordering of the subdivisions is not defined.
Declaration
Swift
@inlinable public func subdivided() -> [`Self`]
-
Returns
true
if this NRectangle’s area intersects the given line type.Declaration
Swift
public func intersects<Line>( line: Line ) -> Bool where Line : LineFloatingPoint, Vector == Line.Vector
-
Declaration
Swift
public func intersection<Line>( with line: Line ) -> ConvexLineIntersection<Vector> where Line: LineFloatingPoint, Vector == Line.Vector
-
Declaration
Swift
public func signedDistance(to point: Vector) -> Vector.Scalar