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

21 lines
921 B
TypeScript

module TK.SpaceTac.Specs {
describe("ArenaLocation", () => {
it("gets distance and angle between two locations", function () {
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);
})
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);
})
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);
});
});
}