 |
Author |
Topic: boids look forward (Read 2074 times) |
|
eskimoblood

|
boids look forward
« on: Oct 14th, 2004, 10:53am » |
|
I've build a boidsystem like explained here: http://www.vergenet.net/~conrad/boids/pseudocode.html Now I'm looking for a algorithm for the second rule that alllows, that a boid only get the distance from the boids in front of them and not from them in the back. I think it has something do to with the angle between the vector of the boid and vector to the other boid.
|
|
|
|
TomC
|
Re: boids look forward
« Reply #1 on: Oct 14th, 2004, 12:56pm » |
|
To find the angle between 2 vectors, you can use the dot product. In 2d, you can use the atan2 function (built into processing). http://processing.org/reference/atan2_.html
|
|
|
|
Fish-face
  

|
Re: boids look forward
« Reply #2 on: Oct 15th, 2004, 9:22am » |
|
You can also use regular trig with Math.[sin|cos|tan|asin|acos|atain] This allows you to do other things - finding other angles, finding a distance from an angle, etc.
|
--
The C@ S@ on the M@ =Fish-Face= ~#Chris#~
|
|
|
|