|
| 1 | +import { assert } from 'chai'; |
| 2 | +import { fromOrientation, IQuaternion } from '../src/quaternion'; |
| 3 | + |
| 4 | +describe('simple Quaternino tests.', () => { |
| 5 | + it('should work with fromOrientation', () => { |
| 6 | + const alpha = fromOrientation({ alpha: 90, beta: 0, gamma: 0 }, 90); |
| 7 | + assert.instanceOf(alpha, IQuaternion); |
| 8 | + console.log(`alpha ${alpha}`); |
| 9 | + assert.closeTo(alpha.x, -0.7071067811865475, 0.001); |
| 10 | + assert.closeTo(alpha.y, 0, 0.001); |
| 11 | + assert.closeTo(alpha.z, 0, 0.001); |
| 12 | + assert.closeTo(alpha.w, 0.7071067811865475, 0.001); |
| 13 | + |
| 14 | + const beta = fromOrientation({ alpha: 0, beta: 90, gamma: 0 }, 90); |
| 15 | + console.log(`beta ${beta}`); |
| 16 | + assert.closeTo(beta.x, 0, 0.001); |
| 17 | + assert.closeTo(beta.y, 0, 0.001); |
| 18 | + assert.closeTo(beta.z, -0.7071067811865475, 0.001); |
| 19 | + assert.closeTo(beta.w, 0.7071067811865475, 0.001); |
| 20 | + |
| 21 | + const gamma = fromOrientation({ alpha: 0, beta: 0, gamma: 90 }, 90); |
| 22 | + console.log(`gamma ${gamma}`); |
| 23 | + assert.closeTo(gamma.x, -0.7071067811865475, 0.001); |
| 24 | + assert.closeTo(gamma.y, 0, 0.001); |
| 25 | + assert.closeTo(gamma.z, -0.7071067811865476, 0.001); |
| 26 | + assert.closeTo(gamma.w, 0, 0.001); |
| 27 | + }); |
| 28 | +}); |
0 commit comments