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
  • end

    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
  • Undocumented

    Declaration

    Swift

    public init(start: Vector, end: Vector, radius: Scalar)
  • Returns a line segment with the same start and end points of this N-capsule.

    Declaration

    Swift

    var asLineSegment: LineSegment<Vector> { get }
  • Returns the NSphere that represents the top- or start, section of this N-capsule, centered around start with a radius of radius.

    Declaration

    Swift

    var startAsSphere: NSphere<Vector> { get }
  • Returns the NSphere that represents the bottom- or end, section of this N-capsule, centered around start with a radius of radius.

    Declaration

    Swift

    var endAsSphere: NSphere<Vector> { get }

Available where Scalar: Comparable & AdditiveArithmetic

  • 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 }

Available where Vector: VectorAdditive & VectorComparable

  • 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 }

Available where Vector: VectorFloatingPoint

  • 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 line asLineSegment is == .zero, an arbitrary closest point along the outer surface of the capsule is returned, instead.

    Declaration

    Swift

    public func project(_ vector: Vector) -> Vector