NSquare

public struct NSquare<Vector> : GeometricType where Vector : VectorType
extension NSquare: Equatable where Vector: Equatable, Scalar: Equatable
extension NSquare: Hashable where Vector: Hashable, Scalar: Hashable
extension NSquare: RectangleType & BoundableType where Vector: VectorAdditive
extension NSquare: VolumetricType where Vector: VectorAdditive & VectorComparable
extension NSquare: ConvexType where Vector: VectorFloatingPoint
extension NSquare: SignedDistanceMeasurableType where Vector: VectorFloatingPoint

Represents an N-dimensional square with an origin point and a scalar value for the side length of each edge.

  • Convenience for Vector.Scalar

    Declaration

    Swift

    public typealias Scalar = Vector.Scalar
  • The location of this box, corresponding to the minimal coordinate of the box’s bounds.

    Declaration

    Swift

    public var location: Vector
  • The length of the side edges of this square.

    Declaration

    Swift

    public var sideLength: Scalar
  • Returns a rectangle with the same boundaries as this square.

    Declaration

    Swift

    public var asRectangle: NRectangle<Vector> { get }
  • Declaration

    Swift

    public init(location: Vector, sideLength: Scalar)

Available where Vector: VectorAdditive

  • Returns the span of this NSquare.

    Declaration

    Swift

    public var size: Vector { get }
  • Returns the minimal AABB capable of containing this NSquare.

    Declaration

    Swift

    public var bounds: AABB<Vector> { get }
  • Returns a list of vertices corresponding to the extremes of this NSquare.

    Precondition

    Currently limited to vectors with < 64 scalars.

    Order of vertices in the result is not defined.

    Declaration

    Swift

    @inlinable
    public var vertices: [Vector] { get }

Available where Vector: VectorAdditive & VectorComparable

  • Returns true if the given vector is contained within the bounds of this square.

    Declaration

    Swift

    @inlinable
    public func contains(_ vector: Vector) -> Bool

Available where Vector: VectorMultiplicative

  • Returns an NSquare with position .zero and side length 1.

    Declaration

    Swift

    static var unit: `Self` { get }

Available where Vector: VectorDivisible

  • Declaration

    Swift

    var center: Vector { get }

Available where Vector: VectorFloatingPoint