Commit b65a61b6 authored by Paul McCarthy's avatar Paul McCarthy 🚵
Browse files

New little function to normalise vectors. Sick of duplicating this code

parent 66ab6c8f
......@@ -22,6 +22,14 @@ spaces. The following functions are provided:
And a few more functions are provided for working with vectors:
.. autosummary::
import numpy as np
......@@ -45,6 +53,16 @@ def concat(*xforms):
return result
def veclength(vec):
"""Returns the length of the given vector. """
return np.sqrt(, vec))
def normalise(vec):
"""Normalises the given vector to unit length. """
return vec / veclength(vec)
def scaleOffsetXform(scales, offsets):
"""Creates and returns an affine transformation matrix which encodes
the specified scale(s) and offset(s).
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment