As an illustration:
Starting from
[x0,x1,x2,x3] - x0 compares itself to x1,x2 and x3.
x1 compares itself to x0, x2 and x3. And so forth...
To
[x0,x1,x2,x3] - x0 compares itself to x1,x2 and x3.
x1 compares itself to x2 and x3 only.
x2 only compares itself to x3.
x3 doesn't have to make any comparisons at all.
My aim is to travel through an array in one specific direction, disregarding all elements before the current one.
for (var i = 0; i < boids.length; i++) {
//boids is an array that includes elements "boid"
var d = distSquared(this.position.x, this.position.y, boids[i].position.x, boids[i].position.y);
//calculate distance between current boid and all other boids in the array.
//Wanting to modify this to determine distance between current boid and all other boids ahead of this element in the array.
if (boids[i] == this) { //if the boid being compared is itself, skip it.
continue;
}
}
How can I establish such a system?