From 1c59c46ce7de927739e4a519ba4cce8a17c0ab41 Mon Sep 17 00:00:00 2001 From: Jim Riecken Date: Tue, 12 May 2015 07:36:58 -0700 Subject: [PATCH] Fix "Vornoi" -> "Voronoi" everywhere. Fixes #27 Changes are all in private code, no functional changes. --- CHANGELOG.md | 2 ++ README.md | 2 +- SAT.js | 48 ++++++++++++++++++++++++------------------------ 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dddfdd6..5537423 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## In development + - Fix "Vornoi" -> "Voronoi" everywhere. Changes are all in private code, no functional changes. (Fixes #27) + ## 0.5.0 (Dec 26, 2014) - **(POTENTIALLY BREAKING CHANGE)** Make `recalc` on `Polygon` more memory efficient. It no longer does any allocations. The `calcPoints`,`edges` and `normals` vector arrays are reused and only created in `setPoints` when the number of new points is different than the current ones. (Fixes #15) diff --git a/README.md b/README.md index 127eb83..05569f3 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ About SAT.js is a simple JavaScript library for performing collision detection (and projection-based collision response) of simple 2D shapes. It uses the [Separating Axis Theorem](http://en.wikipedia.org/wiki/Hyperplane_separation_theorem) (hence the name) It supports detecting collisions between: - - Circles (using Vornoi Regions.) + - Circles (using Voronoi Regions.) - Convex Polygons (and simple Axis-Aligned Boxes, which are of course, convex polygons.) It also supports checking whether a point is inside a circle or polygon. diff --git a/SAT.js b/SAT.js index c368c68..0d6213d 100644 --- a/SAT.js +++ b/SAT.js @@ -671,7 +671,7 @@ return false; } - // Calculates which Vornoi region a point is on a line segment. + // Calculates which Voronoi region a point is on a line segment. // It is assumed that both the line and the point are relative to `(0,0)` // // | (0) | @@ -680,35 +680,35 @@ /** * @param {Vector} line The line segment. * @param {Vector} point The point. - * @return {number} LEFT_VORNOI_REGION (-1) if it is the left region, - * MIDDLE_VORNOI_REGION (0) if it is the middle region, - * RIGHT_VORNOI_REGION (1) if it is the right region. + * @return {number} LEFT_VORONOI_REGION (-1) if it is the left region, + * MIDDLE_VORONOI_REGION (0) if it is the middle region, + * RIGHT_VORONOI_REGION (1) if it is the right region. */ - function vornoiRegion(line, point) { + function voronoiRegion(line, point) { var len2 = line.len2(); var dp = point.dot(line); // If the point is beyond the start of the line, it is in the - // left vornoi region. - if (dp < 0) { return LEFT_VORNOI_REGION; } + // left voronoi region. + if (dp < 0) { return LEFT_VORONOI_REGION; } // If the point is beyond the end of the line, it is in the - // right vornoi region. - else if (dp > len2) { return RIGHT_VORNOI_REGION; } + // right voronoi region. + else if (dp > len2) { return RIGHT_VORONOI_REGION; } // Otherwise, it's in the middle one. - else { return MIDDLE_VORNOI_REGION; } + else { return MIDDLE_VORONOI_REGION; } } - // Constants for Vornoi regions + // Constants for Voronoi regions /** * @const */ - var LEFT_VORNOI_REGION = -1; + var LEFT_VORONOI_REGION = -1; /** * @const */ - var MIDDLE_VORNOI_REGION = 0; + var MIDDLE_VORONOI_REGION = 0; /** * @const */ - var RIGHT_VORNOI_REGION = 1; + var RIGHT_VORONOI_REGION = 1; // ## Collision Tests @@ -818,16 +818,16 @@ response['aInB'] = false; } - // Calculate which Vornoi region the center of the circle is in. - var region = vornoiRegion(edge, point); + // Calculate which Voornoi region the center of the circle is in. + var region = voronoiRegion(edge, point); // If it's the left region: - if (region === LEFT_VORNOI_REGION) { - // We need to make sure we're in the RIGHT_VORNOI_REGION of the previous edge. + if (region === LEFT_VORONOI_REGION) { + // We need to make sure we're in the RIGHT_VORONOI_REGION of the previous edge. edge.copy(polygon['edges'][prev]); // Calculate the center of the circle relative the starting point of the previous edge var point2 = T_VECTORS.pop().copy(circlePos).sub(points[prev]); - region = vornoiRegion(edge, point2); - if (region === RIGHT_VORNOI_REGION) { + region = voronoiRegion(edge, point2); + if (region === RIGHT_VORONOI_REGION) { // It's in the region we want. Check if the circle intersects the point. var dist = point.len(); if (dist > radius) { @@ -846,13 +846,13 @@ } T_VECTORS.push(point2); // If it's the right region: - } else if (region === RIGHT_VORNOI_REGION) { + } else if (region === RIGHT_VORONOI_REGION) { // We need to make sure we're in the left region on the next edge edge.copy(polygon['edges'][next]); // Calculate the center of the circle relative to the starting point of the next edge. point.copy(circlePos).sub(points[next]); - region = vornoiRegion(edge, point); - if (region === LEFT_VORNOI_REGION) { + region = voronoiRegion(edge, point); + if (region === LEFT_VORONOI_REGION) { // It's in the region we want. Check if the circle intersects the point. var dist = point.len(); if (dist > radius) { @@ -897,7 +897,7 @@ } // If this is the smallest overlap we've seen, keep it. - // (overlapN may be null if the circle was in the wrong Vornoi region). + // (overlapN may be null if the circle was in the wrong Voronoi region). if (overlapN && response && Math.abs(overlap) < Math.abs(response['overlap'])) { response['overlap'] = overlap; response['overlapN'].copy(overlapN);