Vector

public protocol Vector : Interpolatable, Equatable

Conforming types can be operated on as vectors composed of Scalar components.

  • Creates a vector for which all components are equal to the given scalar.

    Declaration

    Swift

    init(scalar: Scalar)
  • The length of this vector.

    Declaration

    Swift

    static var length: Int { get }
  • Direct component access. If the given index is >= Self.length, it is a programmer error.

    Declaration

    Swift

    subscript(index: Int) -> Scalar { get set }
  • Returns a vector where each component is clamped by the corresponding components in min and max.

    Declaration

    Swift

    func clamped(min: Self, max: Self) -> Self

    Parameters

    x

    The vector to be clamped.

    min

    Each component in the output vector will >= the corresponding component in this vector.

    max

    Each component in the output vector will be <= the corresponding component in this vector.

  • The empty vector (all scalar components are equal to 0.0).

    Declaration

    Swift

    static var zero: Self { get }
  • Product.

    Declaration

    Swift

    static func * (lhs: Self, rhs: Self) -> Self
  • Product (in place).

    Declaration

    Swift

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

    Declaration

    Swift

    static func / (lhs: Self, rhs: Self) -> Self
  • Quotient (in place).

    Declaration

    Swift

    static func /= (lhs: inout Self, rhs: Self)
  • Sum.

    Declaration

    Swift

    static func + (lhs: Self, rhs: Self) -> Self
  • Sum (in place).

    Declaration

    Swift

    static func += (lhs: inout Self, rhs: Self)
  • Difference.

    Declaration

    Swift

    static func - (lhs: Self, rhs: Self) -> Self
  • Difference (in place).

    Declaration

    Swift

    static func -= (lhs: inout Self, rhs: Self)
  • Scalar-Vector product.

    Declaration

    Swift

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