diff --git a/index.html b/index.html
index 7cb2d61..d3511e4 100644
--- a/index.html
+++ b/index.html
@@ -3,13 +3,23 @@
-
+
Dust
Studying AI movement along arcs with RxJs
+
+ Restart
+ Change direction
+ Change animation speed
+ Show movement circle
+ Show vision grid
+ Show touching points
+ Start / stop
+
+
The ultimate goal is to simulate particles that move in swarms and calculate their
diff --git a/js/animation3.js b/js/animation3.js
index ea77234..cf8d04f 100644
--- a/js/animation3.js
+++ b/js/animation3.js
@@ -55,15 +55,18 @@ function move(store) {
const avgX = xs / 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);
- arc = modifyArc(arc, modifier);
+ arc = modifyArc(arc, 20);
+ // } else if (Math.random() < 0.005) {
+ // console.warn('changing direction')
+ // clockwise = !clockwise;
+ // arc = changeDirection(arc);
} else {
- if (Math.random() < 0.005) {
- console.warn('changing direction')
- }
- arc = modifyArc(arc, Math.random() * 100 + 100);
+ arc = modifyArc(arc, 300);
}
particleX = arc.x + arc.r * Math.cos(arc.t);
@@ -71,6 +74,7 @@ function move(store) {
store.set({
arc,
+ clockwise,
particleX,
particleY,
});
@@ -92,10 +96,11 @@ function modifyArc(arc, newRadius) {
}
function changeDirection(arc) {
- // clockwise = !clockwise;
- // theta = (theta + Math.PI) % t360;
- // circleX -= (radius + radius0) * Math.cos(theta);
- // circleY += (radius + radius0) * Math.sin(theta);
+ arc.t = (arc.t + Math.PI) % t360;
+ arc.x -= (2 * arc.r) * Math.cos(arc.t);
+ arc.y += (2 * arc.r) * Math.sin(arc.t);
+
+ return arc;
}
function detectWall(store) {
diff --git a/js/bundle.js b/js/bundle.js
index 31b9b92..0a16b93 100644
--- a/js/bundle.js
+++ b/js/bundle.js
@@ -6426,15 +6426,18 @@ function move(store) {
var avgX = xs / intersections.length;
var avgY = ys / intersections.length;
- var v = (t90 + Math.atan((particleY - avgY) / (particleX - avgX))) % t90;
+ var v = Math.atan((particleY - avgY) / (particleX - avgX));
+ // console.warn(Math.round(v * 180 / Math.PI))
+
var 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 {
- if (Math.random() < 0.005) {
- console.warn('changing direction');
- }
- arc = modifyArc(arc, Math.random() * 100 + 100);
+ arc = modifyArc(arc, 300);
}
particleX = arc.x + arc.r * Math.cos(arc.t);
@@ -6442,6 +6445,7 @@ function move(store) {
store.set({
arc: arc,
+ clockwise: clockwise,
particleX: particleX,
particleY: particleY
});
@@ -6463,10 +6467,11 @@ function modifyArc(arc, newRadius) {
}
function changeDirection(arc) {
- // clockwise = !clockwise;
- // theta = (theta + Math.PI) % t360;
- // circleX -= (radius + radius0) * Math.cos(theta);
- // circleY += (radius + radius0) * Math.sin(theta);
+ arc.t = (arc.t + Math.PI) % t360;
+ arc.x -= 2 * arc.r * Math.cos(arc.t);
+ arc.y += 2 * arc.r * Math.sin(arc.t);
+
+ return arc;
}
function detectWall(store) {