From a12ad9479783cd95da65cfa1f427f19c1cbad730 Mon Sep 17 00:00:00 2001 From: David Crocker Date: Tue, 2 Aug 2022 12:17:05 +0100 Subject: Eliminated some variables that were not needed --- src/Movement/Move.cpp | 16 ++++++++-------- src/Movement/Move.h | 9 +++++---- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index 754f141e..d94901a9 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -161,9 +161,9 @@ constexpr ObjectModelTableEntry Move::objectModelTable[] = // 8. move.compensation.skew members { "compensateXY", OBJECT_MODEL_FUNC(self->compensateXY), ObjectModelEntryFlags::none }, - { "tanXY", OBJECT_MODEL_FUNC(self->tanXY, 4), ObjectModelEntryFlags::none }, - { "tanXZ", OBJECT_MODEL_FUNC(self->tanXZ, 4), ObjectModelEntryFlags::none }, - { "tanYZ", OBJECT_MODEL_FUNC(self->tanYZ, 4), ObjectModelEntryFlags::none }, + { "tanXY", OBJECT_MODEL_FUNC(self->tanXY(), 4), ObjectModelEntryFlags::none }, + { "tanXZ", OBJECT_MODEL_FUNC(self->tanXZ(), 4), ObjectModelEntryFlags::none }, + { "tanYZ", OBJECT_MODEL_FUNC(self->tanYZ(), 4), ObjectModelEntryFlags::none }, #if SUPPORT_COORDINATE_ROTATION // 8. move.rotation members @@ -228,7 +228,7 @@ void Move::Init() noexcept // Clear the transforms SetIdentityTransform(); compensateXY = true; - tanXY = tanYZ = tanXZ = 0.0; + tangents[0] = tangents[1] = tangents[2] = 0.0; usingMesh = useTaper = false; zShift = 0.0; @@ -618,11 +618,11 @@ void Move::AxisTransform(float xyzPoint[MaxAxes], const Tool *tool) const noexce { if (xAxes.IsBitSet(axis)) { - xyzPoint[axis] += (compensateXY ? tanXY*xyzPoint[lowestYAxis] : 0.0) + tanXZ*xyzPoint[Z_AXIS]; + xyzPoint[axis] += (compensateXY ? tanXY() * xyzPoint[lowestYAxis] : 0.0) + tanXZ() * xyzPoint[Z_AXIS]; } if (yAxes.IsBitSet(axis)) { - xyzPoint[axis] += (compensateXY ? 0.0 : tanXY*xyzPoint[lowestXAxis]) + tanYZ*xyzPoint[Z_AXIS]; + xyzPoint[axis] += (compensateXY ? 0.0 : tanXY() * xyzPoint[lowestXAxis]) + tanYZ() * xyzPoint[Z_AXIS]; } } } @@ -644,11 +644,11 @@ void Move::InverseAxisTransform(float xyzPoint[MaxAxes], const Tool *tool) const { if (yAxes.IsBitSet(axis)) { - xyzPoint[axis] -= ((compensateXY ? 0.0 : tanXY*xyzPoint[lowestXAxis]) + tanYZ*xyzPoint[Z_AXIS]); + xyzPoint[axis] -= ((compensateXY ? 0.0 : tanXY() * xyzPoint[lowestXAxis]) + tanYZ() * xyzPoint[Z_AXIS]); } if (xAxes.IsBitSet(axis)) { - xyzPoint[axis] -= ((compensateXY ? tanXY*xyzPoint[lowestYAxis] : 0.0) + tanXZ*xyzPoint[Z_AXIS]); + xyzPoint[axis] -= ((compensateXY ? tanXY() * xyzPoint[lowestYAxis] : 0.0) + tanXZ() * xyzPoint[Z_AXIS]); } } } diff --git a/src/Movement/Move.h b/src/Movement/Move.h index d16b3e7e..a1414ada 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -283,10 +283,11 @@ private: uint32_t longestGcodeWaitInterval; // the longest we had to wait for a new GCode float tangents[3]; // Axis compensation - 90 degrees + angle gives angle between axes - float& tanXY = tangents[0]; - float& tanYZ = tangents[1]; - float& tanXZ = tangents[2]; - bool compensateXY; + bool compensateXY; // If true then we compensate for XY skew by adjusting the Y coordinate; else we adjust the X coordinate + + float tanXY() const noexcept { return tangents[0]; } + float tanYZ() const noexcept { return tangents[1]; } + float tanXZ() const noexcept { return tangents[2]; } HeightMap heightMap; // The grid definition in use and height map for G29 bed probing RandomProbePointSet probePoints; // G30 bed probe points -- cgit v1.2.3