Skip to content

Commit

Permalink
fix(quaternion): more quaternion tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTelanie committed Oct 4, 2019
1 parent 3b92dae commit 1e89a6c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions test/quternion.js → test/qauternion.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
import { assert } from 'chai';
import { fromOrientation, IQuaternion } from '../src/quaternion';

describe('simple Quaternino tests.', () => {
describe('simple Quaternion 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);

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

const test2 = fromOrientation({ alpha: -90, beta: -90, gamma: -90 }, 0);
assert.closeTo(test2.x, -1, 0.001);
assert.closeTo(test2.y, 0, 0.001);
assert.closeTo(test2.z, 0, 0.001);
assert.closeTo(test2.w, 0, 0.001);
});
});

0 comments on commit 1e89a6c

Please sign in to comment.