VectorComparable

public protocol VectorComparable : VectorType, Equatable where Self.Scalar : Comparable

Represents a VectorType with comparison operators available.

  • maximalComponentIndex Default implementation

    Returns the index of the component of this vector that has the greatest value.

    Vector2D(x: -3.0, y: 2.5).maximalComponentIndex // Returns 1
    

    Default Implementation

    Returns the index of the component of this vector that has the greatest value.

    Vector2D(x: -3.0, y: 2.5).maximalComponentIndex // Returns 1
    

    Declaration

    Swift

    var maximalComponentIndex: Int { get }
  • minimalComponentIndex Default implementation

    Returns the index of the component of this vector that has the least value.

    Vector2D(x: -3.0, y: 2.5).minimalComponentIndex // Returns 0
    

    Default Implementation

    Returns the index of the component of this vector that has the least value.

    Vector2D(x: -3.0, y: 2.5).minimalComponentIndex // Returns 0
    

    Declaration

    Swift

    var minimalComponentIndex: Int { get }
  • maximalComponent Default implementation

    Returns the component of this vector that has the greatest value.

    Vector2D(x: -3.0, y: 2.5).maximalComponent // Returns 2.5
    

    Default Implementation

    Returns the component of this vector that has the greatest value.

    Vector2D(x: -3.0, y: 2.5).maximalComponent // Returns 2.5
    

    Declaration

    Swift

    var maximalComponent: Scalar { get }
  • minimalComponent Default implementation

    Returns the component of this vector that has the least value.

    Vector2D(x: -3.0, y: 2.5).minimalComponent // Returns -3.0
    

    Default Implementation

    Returns the component of this vector that has the least value.

    Vector2D(x: -3.0, y: 2.5).minimalComponent // Returns -3.0
    

    Declaration

    Swift

    var minimalComponent: Scalar { get }
  • Returns the pointwise minimal Vector where each component is the minimal scalar value at each index for both vectors.

    let v1 = Vector2D(x: -3.0, y: 2.5)
    let v2 = Vector2D(x: 4.0, y: -6.2)
    
    print(Vector2D.pointwiseMin(v1, v2)) // Prints "(x: -3.0, y: -6.2)"
    

    Declaration

    Swift

    static func pointwiseMin(_ lhs: Self, _ rhs: Self) -> Self
  • Returns the pointwise maximal Vector where each component is the maximal scalar value at each index for both vectors.

    let v1 = Vector2D(x: -3.0, y: 2.5)
    let v2 = Vector2D(x: 4.0, y: -6.2)
    
    print(Vector2D.pointwiseMax(v1, v2)) // Prints "(x: 4, y: 2.5)"
    

    Declaration

    Swift

    static func pointwiseMax(_ lhs: Self, _ rhs: Self) -> Self
  • <(_:_:) Default implementation

    Compares two vectors and returns true if all components of lhs are less than rhs.

    let v1 = Vector2D(x: 2.0, y: -1)
    let v2 = Vector2D(y: -3.0, y: -2)
    let v3 = Vector2D(y: -4.0, y: -1)
    
    print(v2 < v1) // Prints "true"
    print(v3 < v1) // Prints "false"
    

    Default Implementation

    Compares two vectors and returns true if all components of lhs are less than rhs.

    let v1 = Vector2D(x: 2.0, y: -1)
    let v2 = Vector2D(y: -3.0, y: -2)
    let v3 = Vector2D(y: -4.0, y: -1)
    
    print(v2 < v1) // Prints "true"
    print(v3 < v1) // Prints "false"
    

    Declaration

    Swift

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

    Compares two vectors and returns true if all components of lhs are less than or equal to rhs.

    let v1 = Vector2D(x: 2.0, y: -1)
    let v2 = Vector2D(y: -3.0, y: -2)
    let v3 = Vector2D(y: -4.0, y: -1)
    
    print(v2 <= v1) // Prints "true"
    print(v3 <= v1) // Prints "true"
    

    Default Implementation

    Compares two vectors and returns true if all components of lhs are less than or equal to rhs.

    let v1 = Vector2D(x: 2.0, y: -1)
    let v2 = Vector2D(y: -3.0, y: -2)
    let v3 = Vector2D(y: -4.0, y: -1)
    
    print(v2 <= v1) // Prints "true"
    print(v3 <= v1) // Prints "true"
    

    Declaration

    Swift

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

    Compares two vectors and returns true if all components of lhs are greater than rhs.

    let v1 = Vector2D(x: -2.0, y: 1)
    let v2 = Vector2D(y: 3.0, y: 2)
    let v3 = Vector2D(y: 4.0, y: 1)
    
    print(v2 > v1) // Prints "true"
    print(v3 > v1) // Prints "false"
    

    Default Implementation

    Compares two vectors and returns true if all components of lhs are greater than rhs.

    let v1 = Vector2D(x: -2.0, y: 1)
    let v2 = Vector2D(y: 3.0, y: 2)
    let v3 = Vector2D(y: 4.0, y: 1)
    
    print(v2 > v1) // Prints "true"
    print(v3 > v1) // Prints "false"
    

    Declaration

    Swift

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

    Compares two vectors and returns true if all components of lhs are greater than or equal to rhs.

    let v1 = Vector2D(x: -2.0, y: 1)
    let v2 = Vector2D(y: 3.0, y: 2)
    let v3 = Vector2D(y: 4.0, y: 1)
    
    print(v2 >= v1) // Prints "true"
    print(v3 >= v1) // Prints "true"
    

    Default Implementation

    Compares two vectors and returns true if all components of lhs are greater than or equal to rhs.

    let v1 = Vector2D(x: -2.0, y: 1)
    let v2 = Vector2D(y: 3.0, y: 2)
    let v3 = Vector2D(y: 4.0, y: 1)
    
    print(v2 >= v1) // Prints "true"
    print(v3 >= v1) // Prints "true"
    

    Declaration

    Swift

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