module Geode::VectorComparison(N)
Overview
Comparison operations for vectors.
Intended to be used as a mix-in on vector types. N is the number of components in the vector.
Direct including types
Defined in:
geode/vectors/comparison.crInstance Method Summary
-
#==(other : CommonVector(T, N)) forall T
Checks if components between two vectors are equal.
-
#compare(other : CommonVector(T, N)) : CommonVector(Int32, N) forall T
Compares components of this vector to another.
-
#eq?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
Checks if components between two vectors are equal.
-
#ge?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
Checks if components of this vector are greater than or equal to those from another vector.
-
#gt?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
Checks if components of this vector are greater than those from another vector.
-
#le?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
Checks if components of this vector are less than or equal to those from another vector.
-
#lt?(other : CommonVector(T, N)) : CommonVector(Bool, N) forall T
Checks if components of this vector are less than those from another vector.
-
#near_zero?(tolerance)
Checks if this is close to a zero-vector.
-
#zero?
Checks if this is a zero-vector.
Instance Method Detail
Checks if components between two vectors are equal.
Compares this vector component-wise to another. Returns true if all components are equal, false otherwise.
Vector[1, 2, 3] == Vector3[1, 2, 3] # => true
Vector[1, 2, 3] == Vector3[3, 2, 1] # => false
Compares components of this vector to another.
Each component of the resulting vector is an integer. The value will be:
- -1 if the component from this vector is less than the corresponding component from other.
- 0 if the component from this vector is equal to the corresponding component from other.
- 1 if the component from this vector is greater than the corresponding component from other.
- nil if the components can't be compared.
Vector[1, 2, 3].compare(Vector[3, 2, 1]) # => (-1, 0, 1)
Checks if components between two vectors are equal.
Compares this vector component-wise to another. Returns a bool vector. Components of the resulting vector are true if the corresponding vector components were equal.
Vector[1, 2, 3].eq?(Vector[3, 2, 1]) # => (false, true, false)
Checks if components of this vector are greater than or equal to those from another vector.
Compares this vector component-wise to another. Returns a bool vector. Components of the resulting vector are true if the corresponding component from this vector is greater than or equal to the component from other.
Vector[1, 2, 3].ge?(Vector[3, 2, 1]) # => (false, true, true)
Checks if components of this vector are greater than those from another vector.
Compares this vector component-wise to another. Returns a bool vector. Components of the resulting vector are true if the corresponding component from this vector is greater than the component from other.
Vector[1, 2, 3].gt?(Vector[3, 2, 1]) # => (false, false, true)
Checks if components of this vector are less than or equal to those from another vector.
Compares this vector component-wise to another. Returns a bool vector. Components of the resulting vector are true if the corresponding component from this vector is less than or equal to the component from other.
Vector[1, 2, 3].le?(Vector[3, 2, 1]) # => (true, true, false)
Checks if components of this vector are less than those from another vector.
Compares this vector component-wise to another. Returns a bool vector. Components of the resulting vector are true if the corresponding component from this vector is less than the component from other.
Vector[1, 2, 3].lt?(Vector[3, 2, 1]) # => (true, false, false)
Checks if this is close to a zero-vector.
Returns true if all components of the vector are close to zero.
Vector[0.0, 0.01, 0.001].near_zero?(0.01) # => true
Vector[0.1, 0.0, 0.01].near_zero?(0.01) # => false
Checks if this is a zero-vector.
Returns true if all components of the vector are zero.
See: #near_zero?
Vector[0, 0, 0].zero? # => true
Vector[1, 0, 2].zero? # => false