NCapsule
public struct NCapsule<Vector> : GeometricType where Vector : VectorType
extension NCapsule: Equatable where Vector: Equatable, Scalar: Equatable
extension NCapsule: Hashable where Vector: Hashable, Scalar: Hashable
extension NCapsule: BoundableType where Vector: VectorAdditive & VectorComparable
extension NCapsule: VolumetricType where Vector: VectorFloatingPoint
extension NCapsule: PointProjectableType where Vector: VectorFloatingPoint
Represents an N-dimensional capsule (A
Stadium in 2D, and a
Capsule in 3D),
where all points that are less than radius
distance away from a line
are considered within the geometry.
-
Convenience for
Vector.Scalar
.Declaration
Swift
public typealias Scalar = Vector.Scalar
-
Gets the starting point of this capsule’s geometry.
Declaration
Swift
public var start: Vector
-
Gets the end point of this capsule’s geometry.
Declaration
Swift
public var end: Vector
-
The radius of this capsule.
Declaration
Swift
public var radius: Scalar
-
Declaration
Swift
public init(start: Vector, end: Vector, radius: Scalar)
-
Declaration
Swift
var asLineSegment: LineSegment<Vector> { get }
-
Returns whether this N-capsule’s parameters produce a valid, non-empty capsule.
An N-capsule is valid when
radius
is greater than zero.Declaration
Swift
var isValid: Bool { get }
-
Returns the minimal bounds capable of fully containing this N-capsule’s area.
Is equivalent to a union of the start and end N-spheres of this N-capsule.
Declaration
Swift
public var bounds: AABB<Vector> { get }
-
Returns
true
if a given vector is fully contained within this N-capsule.Points at the perimeter of the N-capsule (distance to line == radius) are considered as contained within the N-capsule.
Declaration
Swift
@inlinable public func contains(_ vector: Vector) -> Bool
-
Returns the closest point on this N-capsule’s surface to
vector
.If the distance between
vector
and its point on the projected lineasLineSegment
is== .zero
, an arbitrary closest point along the outer surface of the capsule is returned, instead.Declaration
Swift
public func project(_ vector: Vector) -> Vector