Skip to content

Commit 3c7188f

Browse files
committed
skip points close to each other
1 parent 95ccaa4 commit 3c7188f

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

cone.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ module.exports = function(vectorfield, bounds) {
3333
var u2 = null;
3434
var positionVectors = [];
3535
var vectorScale = Infinity;
36+
var skipIt = false;
3637
for (var i = 0; i < positions.length; i++) {
3738
var p = positions[i];
3839
minX = Math.min(p[0], minX);
@@ -52,12 +53,19 @@ module.exports = function(vectorfield, bounds) {
5253
//
5354
// The vector scale corresponds to the minimum "time" to travel across two
5455
// two adjacent positions at the average velocity of those two adjacent positions
55-
vectorScale = Math.min(vectorScale,
56-
2 * vec3.distance(p2, p) / (vec3.length(u2) + vec3.length(u))
57-
);
56+
57+
var q = (2 * vec3.distance(p2, p) / (vec3.length(u2) + vec3.length(u)));
58+
if(q) {
59+
vectorScale = Math.min(vectorScale, q);
60+
skipIt = false;
61+
} else {
62+
skipIt = true;
63+
}
64+
}
65+
if(!skipIt) {
66+
p2 = p;
67+
u2 = u;
5868
}
59-
p2 = p;
60-
u2 = u;
6169
positionVectors.push(u);
6270
}
6371
var minV = [minX, minY, minZ];

0 commit comments

Comments
 (0)