From 37bc55883f9eb83e47604df28eb20ff28c568ddb Mon Sep 17 00:00:00 2001 From: Cassio Kirch Date: Sat, 31 Oct 2015 18:27:52 -0200 Subject: [PATCH] BSD indentation with two spaces. --- box.c | 20 ++++---- distance.c | 142 ++++++++++++++++++++++++++--------------------------- nextstep.c | 1 + 3 files changed, 82 insertions(+), 81 deletions(-) diff --git a/box.c b/box.c index 29b48ab..136033d 100644 --- a/box.c +++ b/box.c @@ -11,11 +11,11 @@ initializeBoxes (struct Box* const box) /* The input is an array. */ { unsigned int boxCount; for (boxCount=0; boxCount boxID].first = boid; else - { - while (conductor -> next != 0) - conductor = conductor -> next; - conductor -> next = boid; - } + { + while (conductor -> next != 0) + conductor = conductor -> next; + conductor -> next = boid; + } boid -> previous = conductor; boid -> next = NULL; box[boid -> boxID].last = boid; diff --git a/distance.c b/distance.c index 6a6f7c4..67f7c25 100644 --- a/distance.c +++ b/distance.c @@ -17,92 +17,92 @@ getDistance (const struct Boid* const boid2, const struct Boid* const boid1) 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] - 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.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; } - - else if ((isInEdge (boid1 -> boxID) == true) || \ - (isInEdge (boid2 -> boxID) == true)) + + /* 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) { - - /* 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.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; - } + distance.sine = (boid2 -> position[Y] - temp) / distance.module; + distance.cosine = (boid2 -> position[X] - boid1 -> position[X]) / \ + distance.module; + return distance; } - - /* não vizinhos */ - else + + /* não vizinhos */ + else { distance.sine = 0.0; distance.cosine = 0.0; distance.module = NEIGHBOR_DISTANCE * 2.0; 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. */ diff --git a/nextstep.c b/nextstep.c index 117eabf..c80dcc4 100644 --- a/nextstep.c +++ b/nextstep.c @@ -74,6 +74,7 @@ makeSum (struct Boid* const boid, const struct Boid* conductor, \ else /* Assume endo. */ boid -> endoNeighbors++; #endif + } } conductor = conductor -> next; -- GitLab