Skip to content
Snippets Groups Projects
Commit 43592aa8 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

Improved transform function - is about 1.5 times faster

parent d6ed9a62
No related branches found
No related tags found
No related merge requests found
...@@ -71,22 +71,13 @@ def transform(p, xform, axes=None): ...@@ -71,22 +71,13 @@ def transform(p, xform, axes=None):
""" """
p = _fillPoints(p, axes) p = _fillPoints(p, axes)
t = np.zeros((len(p), 3), dtype=np.float64) t = np.dot(xform[:3, :3].T, p.T).T + xform[3, :3]
x = p[:, 0] if axes is not None:
y = p[:, 1] t = t[:, axes]
z = p[:, 2]
t[:, 0] = x * xform[0, 0] + y * xform[1, 0] + z * xform[2, 0] + xform[3, 0] if t.size == 1: return t[0]
t[:, 1] = x * xform[0, 1] + y * xform[1, 1] + z * xform[2, 1] + xform[3, 1] else: return t
t[:, 2] = x * xform[0, 2] + y * xform[1, 2] + z * xform[2, 2] + xform[3, 2]
if axes is None: axes = [0, 1, 2]
tx = np.array(t[:, axes], dtype=np.float64)
if tx.size == 1: return tx[0]
else: return tx
def _fillPoints(p, axes): def _fillPoints(p, axes):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment