VectorBase

public protocol VectorBase : Equatable

Interface for a mathematical n-component vector, which is a a structure that contains n independent numeric components.

  • The type of the vector’s components.

    Declaration

    Swift

    associatedtype ComponentType : Addable, Numeric
  • The number of components in the vector.

    Declaration

    Swift

    var numberOfComponents: Int { get }
  • The components of this vector.

    Declaration

    Swift

    var components: [ComponentType] { get }
  • Provides access to the individual components.

    Declaration

    Swift

    subscript(index: Int) -> ComponentType { get set }

    Parameters

    index

    The index of the component to get or set.

    Return Value

    The value of the component at the given index.

  • Initializes this instance with all zeroes.

    Declaration

    Swift

    init()
  • Initializes this instance with the specified components. If components does not contain enough elements, the remaining components should be initialized to 0. If components contains too many elements, the extra elements should be ignored.

    Declaration

    Swift

    init(components: [ComponentType])

    Return Value

    a vector initialized with the values of components.

  • Compares two vectors component wise. Returns true if the vectors’ components are the same, false otherwise.

    Declaration

    Swift

    static func == (lhs: Self, rhs: Self) -> Bool