From e428c1793bef1224fc58f9d39f616778aeee5996 Mon Sep 17 00:00:00 2001 From: JH159753 Date: Wed, 2 Nov 2022 01:13:08 -0700 Subject: [PATCH] minor changes --- Boid.pde | 8 +++++--- lab1.pde | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Boid.pde b/Boid.pde index aaba96e..0faa1dc 100644 --- a/Boid.pde +++ b/Boid.pde @@ -109,8 +109,9 @@ class Boid //this checks if there's another target to go to if (currentTarget + 1 < waypoints.size()) { + + //if so, change the speed depending on the angle to the next target - //This part isn't really implemented at all, and I need sleep //We can calculate the angle to the next target with the use of two vectors: one from our location to current target, one from current target to next target //use the dot product of those two vectors; this gives us the angle between them, and we can use that to calculate how much we should slow down @@ -133,7 +134,8 @@ class Boid dotProductOfTargets = (dotProductOfTargets + 1) / 2; //use an ideal speed for our boid, to tell it to either speed up or slow down whether it's going faster than this or not - float idealSpeed = dotProductOfTargets * 80 + 10; + //Square the dot product that's been normalized; it'll change the curve so it slows down more + float idealSpeed = (dotProductOfTargets) * 80 + 5; if (kinematic.getSpeed() < idealSpeed) { kinematic.increaseSpeed(1,0); @@ -150,7 +152,7 @@ class Boid //Ideal speed here should be 80 at dist 85, and reduce linearly from there, hitting 0 at 5 units? //This can be changed later if it isn't good - float idealSpeed = (1 * direction.mag() - 5); + float idealSpeed = (1 * direction.mag() + 5); //if idealSpeed is "negative" we should just set it to 0 if (idealSpeed < 0) { diff --git a/lab1.pde b/lab1.pde index 3f47d8d..9493651 100644 --- a/lab1.pde +++ b/lab1.pde @@ -22,7 +22,7 @@ boolean show_help = false; boolean flocking_enabled = false; void setup() { - size(800, 600); + size(1000, 800); billy = new Boid(BILLY_START, BILLY_START_HEADING, BILLY_MAX_SPEED, BILLY_MAX_ROTATIONAL_SPEED, BILLY_MAX_ACCELERATION, BILLY_MAX_ROTATIONAL_ACCELERATION); randomSeed(0);