From 2498c66cb21734d01b3196e4811fc43f3ea99f5c Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Wed, 16 Nov 2016 17:15:48 +0000 Subject: [PATCH] Changed alignSensors to use temporary variables --- src/main/sensors/boardalignment.c | 48 +++++++++++++++---------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/main/sensors/boardalignment.c b/src/main/sensors/boardalignment.c index b18c558f2..57917e8a1 100644 --- a/src/main/sensors/boardalignment.c +++ b/src/main/sensors/boardalignment.c @@ -64,54 +64,52 @@ static void alignBoard(int32_t *vec) void alignSensors(const int32_t *src, int32_t *dest, uint8_t rotation) { - int32_t x; + const int32_t x = src[X]; + const int32_t y = src[Y]; + const int32_t z = src[Z]; // note src and dest may point to the same address switch (rotation) { default: case CW0_DEG: - dest[X] = src[X]; - dest[Y] = src[Y]; - dest[Z] = src[Z]; + dest[X] = x; + dest[Y] = y; + dest[Z] = z; break; case CW90_DEG: - x = src[X]; - dest[X] = src[Y]; + dest[X] = y; dest[Y] = -x; - dest[Z] = src[Z]; + dest[Z] = z; break; case CW180_DEG: - dest[X] = -src[X]; - dest[Y] = -src[Y]; - dest[Z] = src[Z]; + dest[X] = -x; + dest[Y] = -y; + dest[Z] = z; break; case CW270_DEG: - x = src[X]; - dest[X] = -src[Y]; + dest[X] = -y; dest[Y] = x; - dest[Z] = src[Z]; + dest[Z] = z; break; case CW0_DEG_FLIP: - dest[X] = -src[X]; - dest[Y] = src[Y]; - dest[Z] = -src[Z]; + dest[X] = -x; + dest[Y] = y; + dest[Z] = -z; break; case CW90_DEG_FLIP: - x = src[X]; - dest[X] = src[Y]; + dest[X] = y; dest[Y] = x; - dest[Z] = -src[Z]; + dest[Z] = -z; break; case CW180_DEG_FLIP: - dest[X] = src[X]; - dest[Y] = -src[Y]; - dest[Z] = -src[Z]; + dest[X] = x; + dest[Y] = -y; + dest[Z] = -z; break; case CW270_DEG_FLIP: - x = src[X]; - dest[X] = -src[Y]; + dest[X] = -y; dest[Y] = -x; - dest[Z] = -src[Z]; + dest[Z] = -z; break; }