Skip to content

Commit 327ff8f

Browse files
committed
fix(quaternion): first test for quaternion
1 parent 7d33e4b commit 327ff8f

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

test/quternion.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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

Comments
 (0)