VectorComparable
public protocol VectorComparable : VectorType, Equatable where Self.Scalar : Comparable
Represents a VectorType with comparison operators available.
-
maximalComponentIndexDefault implementationReturns the index of the component of this vector that has the greatest value.
Vector2D(x: -3.0, y: 2.5).maximalComponentIndex // Returns 1Default Implementation
Returns the index of the component of this vector that has the greatest value.
Vector2D(x: -3.0, y: 2.5).maximalComponentIndex // Returns 1Declaration
Swift
var maximalComponentIndex: Int { get } -
minimalComponentIndexDefault implementationReturns the index of the component of this vector that has the least value.
Vector2D(x: -3.0, y: 2.5).minimalComponentIndex // Returns 0Default Implementation
Returns the index of the component of this vector that has the least value.
Vector2D(x: -3.0, y: 2.5).minimalComponentIndex // Returns 0Declaration
Swift
var minimalComponentIndex: Int { get } -
maximalComponentDefault implementationReturns the component of this vector that has the greatest value.
Vector2D(x: -3.0, y: 2.5).maximalComponent // Returns 2.5Default Implementation
Returns the component of this vector that has the greatest value.
Vector2D(x: -3.0, y: 2.5).maximalComponent // Returns 2.5Declaration
Swift
var maximalComponent: Scalar { get } -
minimalComponentDefault implementationReturns the component of this vector that has the least value.
Vector2D(x: -3.0, y: 2.5).minimalComponent // Returns -3.0Default Implementation
Returns the component of this vector that has the least value.
Vector2D(x: -3.0, y: 2.5).minimalComponent // Returns -3.0Declaration
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
trueif all components oflhsare less thanrhs.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
trueif all components oflhsare less thanrhs.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
trueif all components oflhsare less than or equal torhs.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
trueif all components oflhsare less than or equal torhs.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
trueif all components oflhsare greater thanrhs.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
trueif all components oflhsare greater thanrhs.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
trueif all components oflhsare greater than or equal torhs.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
trueif all components oflhsare greater than or equal torhs.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