forked from manrajgrover/algorithms-js
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increase coverage Tangent Between Circles (manrajgrover#36)
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-env mocha */ | ||
const CircleTangents = require('../../../src').algorithms.geometry.CircleTangents; | ||
|
||
const assert = require('assert'); | ||
|
||
describe('Tangent Between Circles', () => { | ||
it('should return empty arrays if tangents do not exist (one circle is contained in the other)', () => { | ||
const circles = new CircleTangents(0, 0, 1, 0, 0, 0.5); | ||
assert.deepEqual(circles.tangents, [[], [], [], []]); | ||
}); | ||
|
||
it('should return 2 external tangents (circles overlap)', () => { | ||
const tangents = new CircleTangents(0, 0, 1, 1, 0, 1).tangents; | ||
assert.deepEqual(tangents[0], [0, 1, 1, 1]); | ||
assert.deepEqual(tangents[1], [0, -1, 1, -1]); | ||
assert.deepEqual(tangents[2], []); | ||
assert.deepEqual(tangents[3], []); | ||
}); | ||
|
||
it('should return 2 external and 2 internal tangents (circles do not overlap)', () => { | ||
const tangents = new CircleTangents(0, 0, 1, 2, 0, 1).tangents; | ||
assert.deepEqual(tangents[0], [0, 1, 2, 1]); | ||
assert.deepEqual(tangents[1], [0, -1, 2, -1]); | ||
assert.deepEqual(tangents[2], [1, 0, 1, 0]); | ||
assert.deepEqual(tangents[3], [1, 0, 1, 0]); | ||
}); | ||
}); |