# `utils`¶

Utilities for transforms3d

 `inique`(iterable) Generate unique elements from iterable Return vector divided by Euclidean (L2) norm Generate permuted signs for sequence seq Return all permutations of seq with all sign permutations `random_unit_vector`([rng]) Return random normalized 3D unit vector Return vector Euclidaan (L2) norm

## inique¶

`transforms3d.utils.``inique`(iterable)

Generate unique elements from iterable

Parameters
iterableiterable
Returns
gengenerator

generator that yields unique elements from iterable

Examples

```>>> tuple(inique([0, 1, 2, 0, 2, 3]))
(0, 1, 2, 3)
```

## normalized_vector¶

`transforms3d.utils.``normalized_vector`(vec)

Return vector divided by Euclidean (L2) norm

Parameters
vecarray-like shape (3,)
Returns
nvecarray shape (3,)

vector divided by L2 norm

Examples

```>>> vec = [1, 2, 3]
>>> l2n = np.sqrt(np.dot(vec, vec))
>>> nvec = normalized_vector(vec)
>>> np.allclose(np.array(vec) / l2n, nvec)
True
>>> vec = np.array([[1, 2, 3]])
>>> vec.shape
(1, 3)
>>> normalized_vector(vec).shape
(3,)
```

## permuted_signs¶

`transforms3d.utils.``permuted_signs`(seq)

Generate permuted signs for sequence seq

Parameters
seqsequence
Returns
gengenerator

generator returning seq with signs permuted

Examples

```>>> tuple(permuted_signs([1, -2, 0]))
((1, -2, 0), (1, -2, 0), (1, 2, 0), (1, 2, 0), (-1, -2, 0), (-1, -2, 0), (-1, 2, 0), (-1, 2, 0))
```

## permuted_with_signs¶

`transforms3d.utils.``permuted_with_signs`(seq)

Return all permutations of seq with all sign permutations

Parameters
seqsequence
Returns
gengenerator

generator returning permutations and sign permutations

Examples

```>>> tuple(permuted_with_signs((1,2)))
((1, 2), (1, -2), (-1, 2), (-1, -2), (2, 1), (2, -1), (-2, 1), (-2, -1))
```

## random_unit_vector¶

`transforms3d.utils.``random_unit_vector`(rng=None)

Return random normalized 3D unit vector

Parameters
rngNone or random number generator, optional

rng must have function / method normal that allows size= keyword.

Returns
vecshape (3,) array

Vector at random on unit sphere.

Notes

https://mathworld.wolfram.com/SpherePointPicking.html

## vector_norm¶

`transforms3d.utils.``vector_norm`(vec)

Return vector Euclidaan (L2) norm

Parameters
vecarray-like shape (3,)
Returns
normscalar

Examples

```>>> vec = [1, 2, 3]
>>> l2n = np.sqrt(np.dot(vec, vec))
>>> nvec = vector_norm(vec)
>>> np.allclose(nvec, np.sqrt(np.dot(vec, vec)))
True
```