summaryrefslogtreecommitdiff
path: root/lib/geometry.c
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-06-23 00:00:14 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-06-23 00:00:14 -0400
commit3ece960188d478d71a880339dba70407a5d0f034 (patch)
treebc2596afc91526b4f768238fc1e0b5fd267c0462 /lib/geometry.c
parent701cde10f6a43a4d0c3409e1a9bde74040baee22 (diff)
downloadfuse_networks-3ece960188d478d71a880339dba70407a5d0f034.tar.gz
fuse_networks-3ece960188d478d71a880339dba70407a5d0f034.tar.bz2
fuse_networks-3ece960188d478d71a880339dba70407a5d0f034.zip
ran clang-format
Diffstat (limited to 'lib/geometry.c')
-rw-r--r--lib/geometry.c88
1 files changed, 44 insertions, 44 deletions
diff --git a/lib/geometry.c b/lib/geometry.c
index ec788f1..2c1987b 100644
--- a/lib/geometry.c
+++ b/lib/geometry.c
@@ -2,54 +2,54 @@
#include "fracture.h"
int edge_to_verts(unsigned int width, bool periodic, unsigned int edge,
- bool index) {
- assert(edge < pow(width, 2));
-
- int x = edge / width + 1;
- int y = edge % width + 1;
-
- if (periodic) {
- return (((index ^ (x % 2)) + 2 * ((y + (index ^ (!(x % 2)))) / 2) - 1) %
- width +
- (x - index) * width) /
- 2;
- } else {
- return ((index ^ (x % 2)) + 2 * ((y + (index ^ (!(x % 2)))) / 2) +
- (x - index) * (width + 1) - 1) /
- 2;
- }
+ bool index) {
+ assert(edge < pow(width, 2));
+
+ int x = edge / width + 1;
+ int y = edge % width + 1;
+
+ if (periodic) {
+ return (((index ^ (x % 2)) + 2 * ((y + (index ^ (!(x % 2)))) / 2) - 1) %
+ width +
+ (x - index) * width) /
+ 2;
+ } else {
+ return ((index ^ (x % 2)) + 2 * ((y + (index ^ (!(x % 2)))) / 2) +
+ (x - index) * (width + 1) - 1) /
+ 2;
+ }
}
int dual_edge_to_verts(unsigned int width, bool periodic, unsigned int edge,
- bool index) {
- assert(edge < pow(width, 2));
-
- int x = edge / width + 1;
- int y = edge % width + 1;
-
- if (periodic) {
- return (((index ^ (!(x % 2))) + 2 * ((y + (index ^ (x % 2))) / 2) - 1) %
- width +
- (x - index) * width) /
- 2;
- } else {
- return ((index ^ (!(x % 2))) + 2 * ((y + (index ^ (x % 2))) / 2) +
- (x - index) * (width + 1) - 1) /
- 2;
- }
+ bool index) {
+ assert(edge < pow(width, 2));
+
+ int x = edge / width + 1;
+ int y = edge % width + 1;
+
+ if (periodic) {
+ return (((index ^ (!(x % 2))) + 2 * ((y + (index ^ (x % 2))) / 2) - 1) %
+ width +
+ (x - index) * width) /
+ 2;
+ } else {
+ return ((index ^ (!(x % 2))) + 2 * ((y + (index ^ (x % 2))) / 2) +
+ (x - index) * (width + 1) - 1) /
+ 2;
+ }
}
double dual_vert_to_coord(unsigned int width, bool periodic, unsigned int vert,
- bool index) {
- if (periodic) {
- if (index)
- return (2 * vert) % width + (2 * vert / width) % 2;
- else
- return 2 * vert / width;
- } else {
- if (index)
- return (2 * vert) % (width + 1);
- else
- return (2 * vert) / (width + 1);
- }
+ bool index) {
+ if (periodic) {
+ if (index)
+ return (2 * vert) % width + (2 * vert / width) % 2;
+ else
+ return 2 * vert / width;
+ } else {
+ if (index)
+ return (2 * vert) % (width + 1);
+ else
+ return (2 * vert) / (width + 1);
+ }
}