Comparison

ScikitSpatial.is_zeroFunction
is_zero(v; kwargs...)

Check if a vector is the zero vector.

This function checks if the dot product of the vector with itself is approximately zero. Keyword arguments can be passed along to isapprox.

Examples

julia> is_zero([0, 0])
true

julia> is_zero([1, 0])
false

julia> is_zero([0, 1e-3])
false

julia> is_zero([0, 1e-3], atol=1e-2)
true
source
ScikitSpatial.are_parallelFunction
are_parallel(u, v; kwargs...) -> Bool

Check if two vectors are parallel.

Two nonzero vectors u and v are parallel if

\[\lvert \texttt{cosine\_similarity}(u, v) \rvert = 0\]

The zero vector is considered to be parallel to all vectors.

Keyword arguments can be passed along to isapprox. The tolerances are used to check if the vector is zero, or if the vectors are otherwise parallel.

Examples

julia> are_parallel([1, 0], [1, 0])
true

julia> are_parallel([1, 0], [5, 0])
true

julia> are_parallel([1, 0], [-5, 0])
true

julia> are_parallel([5, 3], [-10, -6])
true

julia> are_parallel([5, 3], [-10, 6])
false

The zero vector is considered to be parallel to all vectors.

julia> are_parallel([0, 0], [1, 1])
true

julia> are_parallel([1, 1], [0, 0])
true

The tolerances are used to check if the vector is zero, or if the vectors are otherwise parallel.

julia> are_parallel([1, 1], [0, 1e-3])
false

julia> are_parallel([1, 1], [0, 1e-3], atol=1e-2)
true

julia> are_parallel([1, 1], [1, 1.01])
false

julia> are_parallel([1, 1], [1, 1.01], atol=1e-2)
true
source
ScikitSpatial.are_perpendicularFunction
are_perpendicular(u, v; kwargs...) -> Bool

Check if two vectors are perpendicular.

Two vectors u and v are perpendicular if

\[u \cdot v = 0\]

Keyword arguments can be passed along to isapprox.

Examples

julia> are_perpendicular([1, 0], [1, 1])
false

julia> are_perpendicular([1, 0], [0, 1])
true

julia> are_perpendicular([1, 0], [0, -5])
true

julia> are_perpendicular([1, 0], [1e-2, 1])
false

julia> are_perpendicular([1, 0], [1e-2, 1], atol=1e-2)
true
source