Commit 37bc5588 authored by Cassio Kirch's avatar Cassio Kirch

BSD indentation with two spaces.

parent d73a8fa2
...@@ -11,11 +11,11 @@ initializeBoxes (struct Box* const box) /* The input is an array. */ ...@@ -11,11 +11,11 @@ initializeBoxes (struct Box* const box) /* The input is an array. */
{ {
unsigned int boxCount; unsigned int boxCount;
for (boxCount=0; boxCount<BOXES; ++boxCount) for (boxCount=0; boxCount<BOXES; ++boxCount)
{ {
box[boxCount].boxID = boxCount; box[boxCount].boxID = boxCount;
box[boxCount].first = NULL; box[boxCount].first = NULL;
box[boxCount].last = NULL; box[boxCount].last = NULL;
} }
} }
bool bool
...@@ -43,11 +43,11 @@ appendBoid (struct Boid* const boid, struct Box* const box) ...@@ -43,11 +43,11 @@ appendBoid (struct Boid* const boid, struct Box* const box)
if (conductor == NULL) if (conductor == NULL)
box[boid -> boxID].first = boid; box[boid -> boxID].first = boid;
else else
{ {
while (conductor -> next != 0) while (conductor -> next != 0)
conductor = conductor -> next; conductor = conductor -> next;
conductor -> next = boid; conductor -> next = boid;
} }
boid -> previous = conductor; boid -> previous = conductor;
boid -> next = NULL; boid -> next = NULL;
box[boid -> boxID].last = boid; box[boid -> boxID].last = boid;
......
...@@ -17,92 +17,92 @@ getDistance (const struct Boid* const boid2, const struct Boid* const boid1) ...@@ -17,92 +17,92 @@ getDistance (const struct Boid* const boid2, const struct Boid* const boid1)
boid2 -> position[X], \ boid2 -> position[X], \
boid2 -> position[Y]); boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE) if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \
distance.module;
distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \
distance.module;
return distance;
}
else if ((isInEdge (boid1 -> boxID) == true) || \
(isInEdge (boid2 -> boxID) == true))
{
/* 1o boid à esquerda. */
temp = boid1 -> position[X] + RANGE;
distance.module = absDistance (temp, \
boid1 -> position[Y], \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \
distance.module;
distance.cosine = (boid2 -> position[X] - temp) / distance.module;
return distance;
}
/* 1o boid à direita */
temp = boid1 -> position[X] - RANGE;
distance.module = absDistance (temp, \
boid1 -> position[Y], \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{ {
distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \ distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \
distance.module; distance.module;
distance.cosine = (boid2 -> position[X] - temp) / distance.module;
return distance;
}
/* 1o boid abaixo */
temp = boid1 -> position[Y] + RANGE;
distance.module = absDistance (boid1 -> position[X], \
temp, \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - temp) / distance.module;
distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \ distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \
distance.module; distance.module;
return distance; return distance;
} }
else if ((isInEdge (boid1 -> boxID) == true) || \ /* 1o boid acima */
(isInEdge (boid2 -> boxID) == true)) temp = boid1 -> position[Y] - RANGE;
distance.module = absDistance (boid1 -> position[X], \
temp, \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{ {
distance.sine = (boid2 -> position[Y] - temp) / distance.module;
/* 1o boid à esquerda. */ distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \
temp = boid1 -> position[X] + RANGE; distance.module;
distance.module = absDistance (temp, \ return distance;
boid1 -> position[Y], \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \
distance.module;
distance.cosine = (boid2 -> position[X] - temp) / distance.module;
return distance;
}
/* 1o boid à direita */
temp = boid1 -> position[X] - RANGE;
distance.module = absDistance (temp, \
boid1 -> position[Y], \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - boid1 -> position[Y]) / \
distance.module;
distance.cosine = (boid2 -> position[X] - temp) / distance.module;
return distance;
}
/* 1o boid abaixo */
temp = boid1 -> position[Y] + RANGE;
distance.module = absDistance (boid1 -> position[X], \
temp, \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - temp) / distance.module;
distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \
distance.module;
return distance;
}
/* 1o boid acima */
temp = boid1 -> position[Y] - RANGE;
distance.module = absDistance (boid1 -> position[X], \
temp, \
boid2 -> position[X], \
boid2 -> position[Y]);
if (distance.module < NEIGHBOR_DISTANCE)
{
distance.sine = (boid2 -> position[Y] - temp) / distance.module;
distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \
distance.module;
return distance;
}
/* não vizinhos */
else
{
distance.sine = 0.0;
distance.cosine = 0.0;
distance.module = NEIGHBOR_DISTANCE * 2.0;
return distance;
}
} }
/* não vizinhos */ /* não vizinhos */
else else
{ {
distance.sine = 0.0; distance.sine = 0.0;
distance.cosine = 0.0; distance.cosine = 0.0;
distance.module = NEIGHBOR_DISTANCE * 2.0; distance.module = NEIGHBOR_DISTANCE * 2.0;
return distance; return distance;
} }
}
/* não vizinhos */
else
{
distance.sine = 0.0;
distance.cosine = 0.0;
distance.module = NEIGHBOR_DISTANCE * 2.0;
return distance;
}
} }
/* Supõe-se que a função só será chamada para boids vizinhos. */ /* Supõe-se que a função só será chamada para boids vizinhos. */
......
...@@ -74,6 +74,7 @@ makeSum (struct Boid* const boid, const struct Boid* conductor, \ ...@@ -74,6 +74,7 @@ makeSum (struct Boid* const boid, const struct Boid* conductor, \
else /* Assume endo. */ else /* Assume endo. */
boid -> endoNeighbors++; boid -> endoNeighbors++;
#endif #endif
} }
} }
conductor = conductor -> next; conductor = conductor -> next;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment