From 54d4efa2b35e36f9ecb668ef5861718f3c49acd5 Mon Sep 17 00:00:00 2001 From: MrDave Date: Wed, 30 Jun 2021 17:53:15 -0600 Subject: [PATCH] Remove pow function --- src/alg.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/alg.cpp b/src/alg.cpp index 480ca1af..e10afb95 100644 --- a/src/alg.cpp +++ b/src/alg.cpp @@ -1160,10 +1160,12 @@ static void alg_new_location_dist(ctx_cam *cam) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (*(out++)) { - variance_x += pow((x - cent->x),2); - variance_y += pow((y - cent->y),2); + variance_x += ((x - cent->x) * (x - cent->x)); + variance_y += ((y - cent->y) * (y - cent->y)); /* ToDo: We should store this number for the variance calc...*/ - distance_mean += sqrt(pow((x - cent->x), 2) + pow((y - cent->y), 2)); + distance_mean += sqrt( + ((x - cent->x) * (x - cent->x)) + + ((y - cent->y) * (y - cent->y))); if (x > cent->x) { xdist += x - cent->x; @@ -1201,10 +1203,11 @@ static void alg_new_location_dist(ctx_cam *cam) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (*(out++)) { - variance_xy += pow( - sqrt(pow((x - cent->x), 2) + pow((y - cent->y), 2)) - - distance_mean, - 2); + variance_xy += ( + (sqrt(((x - cent->x) * (x - cent->x)) + + ((y - cent->y) * (y - cent->y))) - distance_mean) * + (sqrt(((x - cent->x) * (x - cent->x)) + + ((y - cent->y) * (y - cent->y))) - distance_mean)); } } }