diff options
| author | Stan Seibert <stan@mtrr.org> | 2011-09-19 14:36:13 -0400 |
|---|---|---|
| committer | Stan Seibert <stan@mtrr.org> | 2011-09-19 14:36:13 -0400 |
| commit | a21b05e4727403e2e061234289af9e60e6022e5a (patch) | |
| tree | 7a7d4c5809c370f3e542cfc8cb0bec7c2e4f5cdc /transform.py | |
| parent | cfecff941fc619eb7269128afc62d9c11ae78aff (diff) | |
| parent | a38c56ff1e268298568077af7f03c8ac64c6fb82 (diff) | |
| download | chroma-a21b05e4727403e2e061234289af9e60e6022e5a.tar.gz chroma-a21b05e4727403e2e061234289af9e60e6022e5a.tar.bz2 chroma-a21b05e4727403e2e061234289af9e60e6022e5a.zip | |
merge relayout branch
Diffstat (limited to 'transform.py')
| -rw-r--r-- | transform.py | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/transform.py b/transform.py deleted file mode 100644 index 299da46..0000000 --- a/transform.py +++ /dev/null @@ -1,38 +0,0 @@ -import numpy as np - -def make_rotation_matrix(phi, n): - """ - Make the rotation matrix to rotate points through an angle `phi` - counter-clockwise around the axis `n` (when looking towards +infinity). - - Source: Weissten, Eric W. "Rotation Formula." Mathworld. - """ - n = np.asarray(n)/np.linalg.norm(n) - - return np.cos(phi)*np.identity(3) + (1-np.cos(phi))*np.outer(n,n) + \ - np.sin(phi)*np.array([[0,n[2],-n[1]],[-n[2],0,n[0]],[n[1],-n[0],0]]) - -def rotate(x, phi, n): - """ - Rotate an array of points `x` through an angle phi counter-clockwise - around the axis `n` (when looking towards +infinity). - """ - return np.inner(np.asarray(x),make_rotation_matrix(phi, n)) - -def normalize(x): - "Returns unit vectors in the direction of `x`." - x = np.asarray(x) - - if x.shape[-1] != 3: - raise ValueError('dimension of last axis must be 3.') - - d = len(x.shape) - - if d == 1: - norm = np.sqrt(x.dot(x)) - elif d == 2: - norm = np.sqrt(np.sum(x*x, axis=1))[:,np.newaxis] - else: - raise ValueError('len(`x`.shape) must be zero or one.') - - return x/norm |
