Produce a rotation matrix for an angle in radians about a vector.
(v, angle)
| 30 | |
| 31 | |
| 32 | def _rotation_about_vector(v, angle): |
| 33 | """ |
| 34 | Produce a rotation matrix for an angle in radians about a vector. |
| 35 | """ |
| 36 | vx, vy, vz = v / np.linalg.norm(v) |
| 37 | s = np.sin(angle) |
| 38 | c = np.cos(angle) |
| 39 | t = 2*np.sin(angle/2)**2 # more numerically stable than t = 1-c |
| 40 | |
| 41 | R = np.array([ |
| 42 | [t*vx*vx + c, t*vx*vy - vz*s, t*vx*vz + vy*s], |
| 43 | [t*vy*vx + vz*s, t*vy*vy + c, t*vy*vz - vx*s], |
| 44 | [t*vz*vx - vy*s, t*vz*vy + vx*s, t*vz*vz + c]]) |
| 45 | |
| 46 | return R |
| 47 | |
| 48 | |
| 49 | def _view_axes(E, R, V, roll): |
no test coverage detected
searching dependent graphs…