VectorTakeable

public protocol VectorTakeable : VectorType

Protocol that vector types conform to to indicate that different combinations of their dimensions can be extracted into other known N-dimensional vector types.

Getters

  • subscript(_:_:) Default implementation

    Takes a new 2D vector from a combination of two of the provided dimensions of this vector.

    let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0)
    
    print(vector[.x, .z]) // Prints "(x: 3.5, y: 1.0)"
    print(vector[.z, .y]) // Prints "(x: 1.0, y: 2.1)"
    

    Default Implementation

    Declaration

    Swift

    subscript(x: TakeDimensions, y: TakeDimensions) -> SubVector2 { get }
  • subscript(_:_:_:) Default implementation

    Takes a new 3D vector from a combination of two of the provided dimensions of this vector.

    let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0)
    
    print(vector[.x, .z, .y]) // Prints "(x: 3.5, y: 1.0, z: 2.1)"
    print(vector[.z, .y, .x]) // Prints "(x: 1.0, y: 2.1, x: 3.5)"
    

    Default Implementation

    Declaration

    Swift

    subscript(x: TakeDimensions, y: TakeDimensions, z: TakeDimensions) -> SubVector3 { get }
  • subscript(_:_:_:_:) Default implementation

    Takes a new 4D vector from a combination of two of the provided dimensions of this vector.

    let vector = Vector3D(x: 3.5, y: 2.1, z: 1.0)
    
    print(vector[.x, .z, .y, .z]) // Prints "(x: 3.5, y: 1.0, z: 2.1, w: 2.1)"
    print(vector[.z, .y, .x, .z]) // Prints "(x: 1.0, y: 2.1, x: 3.5, w: 1.0)"
    

    Default Implementation

    Declaration

    Swift

    subscript(x: TakeDimensions, y: TakeDimensions, z: TakeDimensions, w: TakeDimensions) -> SubVector4 { get }