VectorMultiplicative

public protocol VectorMultiplicative : VectorAdditive where Self.Scalar : Numeric

Protocol for Vectors that support multiplication

  • one Default implementation

    A unit-value VectorType value where each component corresponds to its representation of 1.

    Default Implementation

    A unit-value VectorMultiplicative value where each component corresponds to its representation of 1.

    Declaration

    Swift

    static var one: Self { get }
  • lengthSquared Default implementation

    Returns the length squared of this VectorType.

    Performs the computation x0 * x0 + x1 * x1 + ... + xN * xN for any N-dimensional vector type, and is equivalent to the squared distance to the origin of the vector space, or the dot(_:) product of the vector with itself.

    Default Implementation

    Returns the length squared of this VectorType

    Declaration

    Swift

    var lengthSquared: Scalar { get }
  • distanceSquared(to:) Default implementation

    Returns the squared distance between this VectorType and another VectorType.

    Equivalent to (vec - self).distanceSquared.

    Default Implementation

    Returns the squared distance between this VectorType and another VectorType.

    Equivalent to (vec - self).distanceSquared.

    Declaration

    Swift

    func distanceSquared(to vec: Self) -> Scalar
  • Calculates the dot product between this vector and another.

    Performs the computation x1 * y1 + x2 * y2 + ... + xN + yN for any N-dimensional vector type.

    let v1 = Vector2D(x: 3.0, y: -2.0)
    let v2 = Vector2D(x: 2.5, y: 7.0)
    
    print(v1.dot(v2)) // Prints "-6.5"
    

    Declaration

    Swift

    func dot(_ other: Self) -> Scalar
  • lerp(start:end:amount:) Default implementation

    Performs a linear interpolation between two vectors.

    Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

    Default Implementation

    Performs a linear interpolation between two points.

    Passing amount a value of 0 will cause start to be returned; a value of 1 will cause end to be returned.

    Declaration

    Swift

    static func lerp(start: Self, end: Self, amount: Scalar) -> Self

    Parameters

    start

    Start point.

    end

    End point.

    amount

    Value between 0 and 1 indicating the weight of end.

  • Undocumented

    Declaration

    Swift

    static func * (lhs: Self, rhs: Self) -> Self
  • Undocumented

    Declaration

    Swift

    static func * (lhs: Self, rhs: Scalar) -> Self
  • Undocumented

    Declaration

    Swift

    static func * (lhs: Scalar, rhs: Self) -> Self
  • *=(_:_:) Default implementation

    Undocumented

    Default Implementation

    Undocumented

    Declaration

    Swift

    static func *= (lhs: inout Self, rhs: Self)
  • Undocumented

    Declaration

    Swift

    static func *= (lhs: inout Self, rhs: Scalar)