|
|
@ -55,15 +55,18 @@ function move(store) { |
|
|
|
const avgX = xs / intersections.length; |
|
|
|
const avgX = xs / intersections.length; |
|
|
|
const avgY = ys / intersections.length; |
|
|
|
const avgY = ys / intersections.length; |
|
|
|
|
|
|
|
|
|
|
|
const v = (t90 + Math.atan((particleY - avgY) / (particleX - avgX))) % t90; |
|
|
|
const v = Math.atan((particleY - avgY) / (particleX - avgX)); |
|
|
|
|
|
|
|
// console.warn(Math.round(v * 180 / Math.PI))
|
|
|
|
|
|
|
|
|
|
|
|
const modifier = Math.max(Math.round(v * 180 / Math.PI), 20); |
|
|
|
const modifier = Math.max(Math.round(v * 180 / Math.PI), 20); |
|
|
|
|
|
|
|
|
|
|
|
arc = modifyArc(arc, modifier); |
|
|
|
arc = modifyArc(arc, 20); |
|
|
|
|
|
|
|
// } else if (Math.random() < 0.005) {
|
|
|
|
|
|
|
|
// console.warn('changing direction')
|
|
|
|
|
|
|
|
// clockwise = !clockwise;
|
|
|
|
|
|
|
|
// arc = changeDirection(arc);
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (Math.random() < 0.005) { |
|
|
|
arc = modifyArc(arc, 300); |
|
|
|
console.warn('changing direction') |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
arc = modifyArc(arc, Math.random() * 100 + 100); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
particleX = arc.x + arc.r * Math.cos(arc.t); |
|
|
|
particleX = arc.x + arc.r * Math.cos(arc.t); |
|
|
@ -71,6 +74,7 @@ function move(store) { |
|
|
|
|
|
|
|
|
|
|
|
store.set({ |
|
|
|
store.set({ |
|
|
|
arc, |
|
|
|
arc, |
|
|
|
|
|
|
|
clockwise, |
|
|
|
particleX, |
|
|
|
particleX, |
|
|
|
particleY, |
|
|
|
particleY, |
|
|
|
}); |
|
|
|
}); |
|
|
@ -92,10 +96,11 @@ function modifyArc(arc, newRadius) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function changeDirection(arc) { |
|
|
|
function changeDirection(arc) { |
|
|
|
// clockwise = !clockwise;
|
|
|
|
arc.t = (arc.t + Math.PI) % t360; |
|
|
|
// theta = (theta + Math.PI) % t360;
|
|
|
|
arc.x -= (2 * arc.r) * Math.cos(arc.t); |
|
|
|
// circleX -= (radius + radius0) * Math.cos(theta);
|
|
|
|
arc.y += (2 * arc.r) * Math.sin(arc.t); |
|
|
|
// circleY += (radius + radius0) * Math.sin(theta);
|
|
|
|
|
|
|
|
|
|
|
|
return arc; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function detectWall(store) { |
|
|
|
function detectWall(store) { |
|
|
|