differt.geometry.orthogonal_basis

Contents

differt.geometry.orthogonal_basis#

orthogonal_basis(u)[source]#

Generate v and w, two other arrays of unit vectors that form with input u an orthogonal basis.

Parameters:

u (Float[ArrayLike, '*batch 3']) – The first direction of the orthogonal basis. It must have a unit length.

Return type:

tuple[Float[Array, '*batch 3'], Float[Array, '*batch 3']]

Returns:

A pair of unit vectors, v and w.

Examples

The following example shows how this function works on basic input vectors.

>>> from differt.geometry import (
...     normalize,
...     orthogonal_basis,
... )
>>>
>>> u = jnp.array([1.0, 0.0, 0.0])
>>> orthogonal_basis(u)
(Array([-0., 1.,  0.], dtype=float32), Array([ 0., -0., 1.], dtype=float32))
>>> u, _ = normalize(jnp.array([1.0, 1.0, 1.0]))
>>> orthogonal_basis(u)
(Array([-0.       , -0.7071068,  0.7071068], dtype=float32),
 Array([ 0.8164966, -0.4082483, -0.4082483], dtype=float32))