FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Simulation, Artificial Life
(Moderator: REAS)
   boids look forward
« Previous topic | Next topic »

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

222550793222550793 WWW
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

WWW
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

308232952308232952thedemonsheep WWW Email
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#~
Pages: 1 

« Previous topic | Next topic »