Algosim documentation: ArePerpendicular

ArePerpendicular

Checks if two vectors are orthogonal.

Syntax

Description

If u and v are vectors of the same dimension, then ArePerpendicular(u, v, ε) is true iff u and v are orthogonal, that is, iff their inner product (u|v) = 0. The specified value of ε will be used as the epsilon for floating-point comparisons. If not specified, a default epsilon will be used.

Notes

The infix operator is implemented by the ArePerpendicular function. This operator doesn’t support a custom epsilon.

Examples

❨1, 1, 0❩ ⟂ ❨0, 0, 1❩
true
u, v ≔ ❨1, 1, 1❩/√3, ❨1, −2, 1❩/√6; x ≔ ❨4, 1, 3❩;
p ≔ (x|u)⋅u + (x|v)⋅v;
(x − p) ⟂ u
true
(x − p) ⟂ v
true
ArePerpendicular(❨1, 0, 0❩, ❨0.0001, 1, 0❩, 1E−3)
true

See also