Normalizes a numpy array of points.
(a, axis=-1, order=2)
| 33 | |
| 34 | |
| 35 | def normalized(a, axis=-1, order=2): |
| 36 | """Normalizes a numpy array of points.""" |
| 37 | l2 = np.atleast_1d(np.linalg.norm(a, order, axis)) |
| 38 | l2[l2 == 0] = 1 |
| 39 | return a / np.expand_dims(l2, axis), l2 |
| 40 | |
| 41 | |
| 42 | class LineMesh(object): |