diff options
| author | Elijah Thomas <42302100+elijah-thomas774@users.noreply.github.com> | 2024-05-12 12:46:06 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-05-12 12:46:06 -0400 |
| commit | 2cd0b3a53a3c49b02bd2fbb498c8d41fc1198283 (patch) | |
| tree | a7ac96cc9fe2b15adab6d2d9b1dd7c06a9b47375 /src | |
| parent | 126c5db9431bef2b6f032bce673d7c3d61e62aa3 (diff) | |
| parent | 3e76db8b16a3034f0cbe3290ed0f2d42ef44f472 (diff) | |
Merge pull request #38 from robojumper/m_angle
m_angle
Diffstat (limited to 'src')
| -rw-r--r-- | src/m/m_angle.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/m/m_angle.cpp b/src/m/m_angle.cpp new file mode 100644 index 00000000..a9e9474f --- /dev/null +++ b/src/m/m_angle.cpp @@ -0,0 +1,30 @@ +#include <m/m_angle.h> + +/** 80575c08 */ +mAng3_c mAng3_c::Zero = mAng3_c::mAng3_c(0, 0, 0); + +/** 802ee5f0 */ +s32 mAng::step(s16 target, s32 steps, s16 max, s16 min) { + if (mVal != target) { + int stepSize; + int diff = target - mVal; + stepSize = diff / steps; + if (stepSize > min || stepSize < -min) { + mVal += stepSize < -max ? -max : stepSize > max ? max : stepSize; + } else if (diff >= 0) { + if (mVal + min >= target) { + mVal = target; + } else { + mVal += min; + } + } else { + if (mVal - min <= target) { + mVal = target; + } else { + mVal -= min; + } + } + } + + return target - mVal; +} |
