Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update frame.js #296

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions test/frame.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
describe('Frame', function(){
describe('#finger()', function(){
it('should return a valid finger when requested', function(){
var data = fakeFrame({fingers: 2})
var frame = createFrame(data);
let data = fakeFrame({fingers: 2})
let frame = createFrame(data);
assert.equal(2, frame.fingers.length);
assert(frame.finger(0).valid);
assert(frame.finger(1).valid);
})

it('should return an invalid finger when an invalid finger is requested', function(){
var data = fakeFrame()
var frame = createFrame(data);
let data = fakeFrame()
let frame = createFrame(data);
assert.equal(0, frame.fingers.length);
assert.equal(false, frame.finger(0).valid);
})
})

describe('#fingers', function(){
it('should return a list of fingers', function(){
var data = fakeFrame({fingers: 2})
var frame = createFrame(data);
let data = fakeFrame({fingers: 2})
let frame = createFrame(data);
assert.equal(2, frame.fingers.length);
assert(frame.fingers[0].valid);
assert(frame.fingers[1].valid);
Expand All @@ -28,47 +28,47 @@ describe('Frame', function(){

describe('#hand()', function(){
it('should return a valid hand when requested', function(){
var data = fakeFrame({hands: 1})
var frame = createFrame(data);
let data = fakeFrame({hands: 1})
let frame = createFrame(data);
assert.equal(1, frame.hands.length);
assert(frame.hand(0).valid);
})

it('should return an invalid hand when an invalid hand is requested', function(){
var data = fakeFrame()
var frame = createFrame(data);
let data = fakeFrame()
let frame = createFrame(data);
assert.equal(0, frame.hands.length);
assert.equal(false, frame.hand(0).valid);
})
})

describe('#hands', function(){
it('should return a list of valid hands', function(){
var data = fakeFrame({hands:1})
var frame = createFrame(data);
let data = fakeFrame({hands:1})
let frame = createFrame(data);
assert.equal(1, frame.hands.length);
assert(frame.hands[0].valid);
})
})

describe('#translation()', function(){
it('should return the translation', function(){
var data1 = fakeFrame({translation: [1, 2, 3]})
var frame1 = createFrame(data1);
var data2 = fakeFrame({translation: [3, 1, 5]})
var frame2 = createFrame(data2);
var t = frame1.translation(frame2);
let data1 = fakeFrame({translation: [1, 2, 3]})
let frame1 = createFrame(data1);
let data2 = fakeFrame({translation: [3, 1, 5]})
let frame2 = createFrame(data2);
let t = frame1.translation(frame2);
assert.deepEqual([-2, 1, -2], [t[0], t[1], t[2]]);
})
})

describe('#rotationAxis()', function(){
it('should return the rotationAxis', function(){
var data1 = fakeFrame({rotation: [[0,1,2], [2,3,4], [2,3,4]]})
var frame1 = createFrame(data1);
var data2 = fakeFrame({rotation: [[0,4,5], [1,3,7], [5,4,2]]})
var frame2 = createFrame(data2);
var result = frame1.rotationAxis(frame2);
let data1 = fakeFrame({rotation: [[0,1,2], [2,3,4], [2,3,4]]})
let frame1 = createFrame(data1);
let data2 = fakeFrame({rotation: [[0,4,5], [1,3,7], [5,4,2]]})
let frame2 = createFrame(data2);
let result = frame1.rotationAxis(frame2);
assert.closeTo(-0.7427813, result[0], 0.0001)
assert.closeTo(-0.55708, result[1], 0.0001)
assert.closeTo(-0.37139, result[2], 0.0001)
Expand All @@ -77,11 +77,11 @@ describe('Frame', function(){

describe('#rotationAngle()', function(){
it('should return the rotationAngle', function(){
var data1 = fakeFrame({rotation: [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]})
var frame1 = createFrame(data1);
var data2 = fakeFrame({rotation: [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.5,0.0,0.5]]})
var frame2 = createFrame(data2);
var result = frame1.rotationAngle(frame2);
let data1 = fakeFrame({rotation: [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.0,0.0,1.0]]})
let frame1 = createFrame(data1);
let data2 = fakeFrame({rotation: [[1.0,0.0,0.0], [0.0,1.0,0.0], [0.5,0.0,0.5]]})
let frame2 = createFrame(data2);
let result = frame1.rotationAngle(frame2);
assert.closeTo(0.72273, result, 0.0001);
})
})
Expand All @@ -101,7 +101,7 @@ describe('Frame', function(){
});

describe('End to End', function(){
var frame = fakeActualFrame();
let frame = fakeActualFrame();

it('should have five pointables', function(){
assert.equal(frame.pointables.length, 5, 'five pointables found');
Expand All @@ -112,8 +112,8 @@ describe('Frame', function(){
});

frame.pointables.forEach(function (pointable) {
var stp = pointable.stabilizedTipPosition;
var match = undefined;
let stp = pointable.stabilizedTipPosition;
let match = undefined;
frame.pointables.forEach(function(p) {
if(p.stabilizedTipPosition[0] == stp[0] &&
p.stabilizedTipPosition[1] == stp[1] &&
Expand All @@ -124,15 +124,15 @@ describe('Frame', function(){

assert.ok(match, 'found a match for stp ' + stp.join(','));
assert.ok(match.id, 'match has an ID');
var foundPointable = frame.pointable(match.id);
let foundPointable = frame.pointable(match.id);
assert.ok(foundPointable, 'found the pointable by id in frame');
assert.equal(foundPointable.stabilizedTipPosition[0], stp[0], 'stp match')

var hand = frame.hand(match.handId);
let hand = frame.hand(match.handId);

assert.ok(hand, 'frame has pointables hand');

var hand_pointable = hand.finger(match.id);
let hand_pointable = hand.finger(match.id);

assert.ok(hand_pointable, 'found finger in its hand; also , is finger');
});
Expand Down