utils

Utilities for transforms3d

inique(iterable) Generate unique elements from iterable
normalized_vector(vec) Return vector divided by Euclidean (L2) norm
permuted_signs(seq) Generate permuted signs for sequence seq
permuted_with_signs(seq) Return all permutations of seq with all sign permutations
vector_norm(vec) Return vector Euclidaan (L2) norm

inique

transforms3d.utils.inique(iterable)

Generate unique elements from iterable

Parameters:

iterable : iterable

Returns:

gen : generator

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

See unit vector and Euclidean norm

Parameters:

vec : array-like shape (3,)

Returns:

nvec : array 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:

seq : sequence

Returns:

gen : generator

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:

seq : sequence

Returns:

gen : generator

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))

vector_norm

transforms3d.utils.vector_norm(vec)

Return vector Euclidaan (L2) norm

See unit vector and Euclidean norm

Parameters:vec : array-like shape (3,)
Returns:norm : scalar

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