LineFloatingPoint

public protocol LineFloatingPoint : LineDivisible, PointProjectableType, SignedDistanceMeasurableType where Self.Vector : VectorFloatingPoint

Protocol for objects that form geometric lines with two floating-point vectors representing two points on the line.

  • projectUnclamped(_:) Default implementation

    Performs a vector projection of a given vector with respect to this line. The resulting vector lies within the infinite line formed by extending a <-> b.

    project(_:)

    Default Implementation

    Declaration

    Swift

    func projectUnclamped(_ vector: Vector) -> Vector
  • projectedMagnitude(_:) Default implementation

    Returns the result of creating a projection of this line’s start point projected towards this line’s end point, with a total magnitude of scalar.

    For scalar == 0, returns self.a, for scalar == self.length, returns self.b.

    Default Implementation

    Declaration

    Swift

    func projectedMagnitude(_ scalar: Magnitude) -> Vector

    Parameters

    scalar

    A non-normalized magnitude that describes the length along the slope of this line to generate the point out of.

  • projectedNormalizedMagnitude(_:) Default implementation

    Returns the result of creating a projection of this line’s start point projected towards this line’s end point, with a normalized magnitude of scalar.

    For scalar == 0, returns self.a, for scalar == 1, returns self.b

    Default Implementation

    Declaration

    Swift

    func projectedNormalizedMagnitude(_ scalar: Magnitude) -> Vector

    Parameters

    scalar

    A normalized magnitude that describes the length along the slope of this line to generate the point out of. Values outside the range [0, 1] are allowed and equate to projections past the endpoints of the line.

  • Returns true if a normalized, projected scalar representing a segment of this line with the same starting point and direction, with length = self.length * scalar, lies within the boundaries of this line.

    For infinite lines, all projected scalars lie within the line, while in line segments bounded with start/end points, only values laying in (0-1) are contained on the line.

    Declaration

    Swift

    func containsProjectedNormalizedMagnitude(_ scalar: Magnitude) -> Bool
  • Returns a projected normalized magnitude that is guaranteed to be contained in this line.

    Declaration

    Swift

    func clampProjectedNormalizedMagnitude(_ scalar: Magnitude) -> Magnitude
  • distanceSquared(to:) Default implementation

    Returns the squared distance between this line and a given vector.

    Seealso

    distance(to:)

    Default Implementation

    Undocumented

    Declaration

    Swift

    func distanceSquared(to vector: Vector) -> Vector.Scalar
  • distance(to:) Default implementation

    Returns the distance between this line and a given vector.

    Equivalent to self.distanceSquared(to: vector).squareRoot().

    Default Implementation

    Undocumented

    Declaration

    Swift

    func distance(to vector: Vector) -> Vector.Scalar
  • project(_:) Extension method

    Returns the closest point on this line to a given point.

    The point is limited to the line’s bounds using clampProjectedNormalizedMagnitude(_:), so it’s guaranteed to be within a <-> b.

    Declaration

    Swift

    @inlinable
    func project(_ vector: Vector) -> Vector
  • signedDistance(to:) Extension method

    Declaration

    Swift

    func signedDistance(to point: Vector) -> Vector.Scalar