Skip to content

Commit

Permalink
fix(quaternion): first test for quaternion
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Sep 29, 2019
1 parent 7d33e4b commit 327ff8f
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/quternion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { assert } from 'chai';
import { fromOrientation, IQuaternion } from '../src/quaternion';

describe('simple Quaternino tests.', () => {
it('should work with fromOrientation', () => {
const alpha = fromOrientation({ alpha: 90, beta: 0, gamma: 0 }, 90);
assert.instanceOf(alpha, IQuaternion);
console.log(`alpha ${alpha}`);
assert.closeTo(alpha.x, -0.7071067811865475, 0.001);
assert.closeTo(alpha.y, 0, 0.001);
assert.closeTo(alpha.z, 0, 0.001);
assert.closeTo(alpha.w, 0.7071067811865475, 0.001);

const beta = fromOrientation({ alpha: 0, beta: 90, gamma: 0 }, 90);
console.log(`beta ${beta}`);
assert.closeTo(beta.x, 0, 0.001);
assert.closeTo(beta.y, 0, 0.001);
assert.closeTo(beta.z, -0.7071067811865475, 0.001);
assert.closeTo(beta.w, 0.7071067811865475, 0.001);

const gamma = fromOrientation({ alpha: 0, beta: 0, gamma: 90 }, 90);
console.log(`gamma ${gamma}`);
assert.closeTo(gamma.x, -0.7071067811865475, 0.001);
assert.closeTo(gamma.y, 0, 0.001);
assert.closeTo(gamma.z, -0.7071067811865476, 0.001);
assert.closeTo(gamma.w, 0, 0.001);
});
});

0 comments on commit 327ff8f

Please sign in to comment.