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

Increase coverage Tangent Between Circles #36

Merged
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
27 changes: 27 additions & 0 deletions test/algorithms/geometry/testTangentBetweenCircles.js
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]);
});
});