From bb099f0fd084c3a2f84532e76928a4f548bf188e Mon Sep 17 00:00:00 2001 From: Mike Turvey Date: Wed, 15 Feb 2017 22:55:23 -0700 Subject: Eliminate unnecessary pow calls. --- tools/lighthousefind_tori/main.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'tools/lighthousefind_tori/main.c') diff --git a/tools/lighthousefind_tori/main.c b/tools/lighthousefind_tori/main.c index ee56b37..e94268c 100644 --- a/tools/lighthousefind_tori/main.c +++ b/tools/lighthousefind_tori/main.c @@ -64,7 +64,18 @@ static void runTheNumbers() printf("Using %d sensors to find lighthouse.\n", sensorCount); - Point lh = SolveForLighthouse(to, 1); + Point lh; + for (int i = 0; i < 200; i++) + { + lh = SolveForLighthouse(to, 0); + //(0.156754, -2.403268, 2.280167) + assert(fabs((lh.x / 0.156754) - 1) < 0.00001); + assert(fabs((lh.y / -2.403268) - 1) < 0.00001); + assert(fabs((lh.z / 2.280167) - 1) < 0.00001); + assert(lh.x > 0); + assert(lh.y < 0); + assert(lh.z > 0); + } printf("(%f, %f, %f)\n", lh.x, lh.y, lh.z); -- cgit v1.2.3 From 2927962bd7f9dcb6054d4bf642bb02b946379e25 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 16 Feb 2017 16:02:02 -0700 Subject: Optimizing find_tori, replace 3 trigs with 1 sqrt --- tools/lighthousefind_tori/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tools/lighthousefind_tori/main.c') diff --git a/tools/lighthousefind_tori/main.c b/tools/lighthousefind_tori/main.c index e94268c..bf10820 100644 --- a/tools/lighthousefind_tori/main.c +++ b/tools/lighthousefind_tori/main.c @@ -65,15 +65,16 @@ static void runTheNumbers() printf("Using %d sensors to find lighthouse.\n", sensorCount); Point lh; + //for (int i = 0; i < 200; i++) for (int i = 0; i < 200; i++) - { + { lh = SolveForLighthouse(to, 0); //(0.156754, -2.403268, 2.280167) - assert(fabs((lh.x / 0.156754) - 1) < 0.00001); - assert(fabs((lh.y / -2.403268) - 1) < 0.00001); - assert(fabs((lh.z / 2.280167) - 1) < 0.00001); + assert(fabs((lh.x / 0.1419305302702402) - 1) < 0.00001); + assert(fabs((lh.y / 2.5574949720325431) - 1) < 0.00001); + assert(fabs((lh.z / 2.2451193935772080) - 1) < 0.00001); assert(lh.x > 0); - assert(lh.y < 0); + assert(lh.y > 0); assert(lh.z > 0); } -- cgit v1.2.3 From 27b29c8ec4247dca2d303f4b1ccb29f26b864010 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Tue, 21 Feb 2017 13:44:59 -0700 Subject: Comment out some debug code --- tools/lighthousefind_tori/main.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tools/lighthousefind_tori/main.c') diff --git a/tools/lighthousefind_tori/main.c b/tools/lighthousefind_tori/main.c index bf10820..d3a9f27 100644 --- a/tools/lighthousefind_tori/main.c +++ b/tools/lighthousefind_tori/main.c @@ -66,16 +66,16 @@ static void runTheNumbers() Point lh; //for (int i = 0; i < 200; i++) - for (int i = 0; i < 200; i++) - { + for (int i = 0; i < 1; i++) + { lh = SolveForLighthouse(to, 0); //(0.156754, -2.403268, 2.280167) - assert(fabs((lh.x / 0.1419305302702402) - 1) < 0.00001); - assert(fabs((lh.y / 2.5574949720325431) - 1) < 0.00001); - assert(fabs((lh.z / 2.2451193935772080) - 1) < 0.00001); - assert(lh.x > 0); - assert(lh.y > 0); - assert(lh.z > 0); + //assert(fabs((lh.x / 0.1419305302702402) - 1) < 0.00001); + //assert(fabs((lh.y / 2.5574949720325431) - 1) < 0.00001); + //assert(fabs((lh.z / 2.2451193935772080) - 1) < 0.00001); + //assert(lh.x > 0); + //assert(lh.y > 0); + //assert(lh.z > 0); } printf("(%f, %f, %f)\n", lh.x, lh.y, lh.z); -- cgit v1.2.3