1
0
Fork 0
spacetac/src/core/ArenaLocation.spec.ts

23 lines
1 KiB
TypeScript
Raw Permalink Normal View History

2017-09-24 22:23:22 +00:00
module TK.SpaceTac.Specs {
2017-10-26 21:47:13 +00:00
testing("ArenaLocation", test => {
test.case("gets distance and angle between two locations", check => {
check.nears(arenaDistance({ x: 0, y: 0 }, { x: 1, y: 1 }), Math.sqrt(2));
check.nears(arenaAngle({ x: 0, y: 0 }, { x: 1, y: 1 }), Math.PI / 4);
2017-10-03 16:11:30 +00:00
})
test.case("computes an angular difference", check => {
check.equals(angularDifference(0.5, 1.5), 1.0);
check.nears(angularDifference(0.5, 1.5 + Math.PI * 6), 1.0);
check.same(angularDifference(0.5, -0.5), -1.0);
check.nears(angularDifference(0.5, -0.3 - Math.PI * 4), -0.8);
check.nears(angularDifference(-3 * Math.PI / 4, 3 * Math.PI / 4), -Math.PI / 2);
check.nears(angularDifference(3 * Math.PI / 4, -3 * Math.PI / 4), Math.PI / 2);
2017-10-03 16:11:30 +00:00
})
2017-10-03 20:56:25 +00:00
2017-10-26 21:47:13 +00:00
test.case("converts between degrees and radians", check => {
check.nears(degrees(Math.PI / 2), 90);
check.nears(radians(45), Math.PI / 4);
2017-10-03 20:56:25 +00:00
});
});
}