(vector, axis, angle)
| 416 | // axis is 0 (x), 1 (y), or 2 (z) |
| 417 | // angle is in degrees |
| 418 | function rotateCartesian(vector, axis, angle) { |
| 419 | var angleRads = angle * radians; |
| 420 | var vectorOut = vector.slice(); |
| 421 | var ax1 = (axis === 0) ? 1 : 0; |
| 422 | var ax2 = (axis === 2) ? 1 : 2; |
| 423 | var cosa = Math.cos(angleRads); |
| 424 | var sina = Math.sin(angleRads); |
| 425 | |
| 426 | vectorOut[ax1] = vector[ax1] * cosa - vector[ax2] * sina; |
| 427 | vectorOut[ax2] = vector[ax2] * cosa + vector[ax1] * sina; |
| 428 | |
| 429 | return vectorOut; |
| 430 | } |
| 431 | function eulerFromQuaternion(q) { |
| 432 | return [ |
| 433 | Math.atan2(2 * (q[0] * q[1] + q[2] * q[3]), 1 - 2 * (q[1] * q[1] + q[2] * q[2])) * degrees, |
no outgoing calls
no test coverage detected
searching dependent graphs…