VectorComparable
public protocol VectorComparable : VectorType, Equatable where Self.Scalar : Comparable
Represents a VectorType
with comparison operators available.
-
maximalComponentIndex
Default implementationReturns 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 implementationReturns 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 implementationReturns 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 implementationReturns 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 oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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
true
if all components oflhs
are 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