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)
-
Returns the span of this
NSquare
.Declaration
Swift
public var size: 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 }
-
Returns
true
if the given vector is contained within the bounds of this square.Declaration
Swift
@inlinable public func contains(_ vector: Vector) -> Bool
-
Returns an
NSquare
with position.zero
and side length1
.Declaration
Swift
static var unit: `Self` { get }
-
Declaration
Swift
var center: Vector { get }
-
Returns whether a given line intersects with this square.
Declaration
Swift
public func intersects<Line>( line: Line ) -> Bool where Line: LineFloatingPoint, Line.Vector == 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