2017-09-24 22:23:22 +00:00
|
|
|
module TK.SpaceTac.Specs {
|
2017-06-22 22:37:38 +00:00
|
|
|
describe("ArenaLocation", () => {
|
2017-10-03 16:11:30 +00:00
|
|
|
it("gets distance and angle between two locations", function () {
|
2017-06-22 22:37:38 +00:00
|
|
|
expect(arenaDistance({ x: 0, y: 0 }, { x: 1, y: 1 })).toBeCloseTo(Math.sqrt(2), 8);
|
|
|
|
expect(arenaAngle({ x: 0, y: 0 }, { x: 1, y: 1 })).toBeCloseTo(Math.PI / 4, 8);
|
2017-10-03 16:11:30 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
it("gets an angular distance", function () {
|
|
|
|
expect(angularDistance(0.5, 1.5)).toBe(1.0);
|
|
|
|
expect(angularDistance(0.5, 1.5 + Math.PI * 6)).toBeCloseTo(1.0, 0.000001);
|
|
|
|
expect(angularDistance(0.5, -0.5)).toBe(-1.0);
|
|
|
|
expect(angularDistance(0.5, -0.3 - Math.PI * 4)).toBeCloseTo(-0.8, 0.000001);
|
|
|
|
})
|
2017-10-03 20:56:25 +00:00
|
|
|
|
|
|
|
it("converts between degrees and radians", function () {
|
|
|
|
expect(degrees(Math.PI / 2)).toBeCloseTo(90, 0.000001);
|
|
|
|
expect(radians(45)).toBeCloseTo(Math.PI / 4, 0.000001);
|
|
|
|
});
|
2017-06-22 22:37:38 +00:00
|
|
|
});
|
|
|
|
}
|