.. _program_listing_file_src_LouLib_Math_MathFunctions.cpp: Program Listing for File MathFunctions.cpp ========================================== |exhale_lsh| :ref:`Return to documentation for file ` (``src/LouLib/Math/MathFunctions.cpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #include "MathFunctions.hpp" #include namespace LouLib{ namespace Math{ int signum(double a){ if(a == 0) return 0; return a > 0 ? 1 : -1; } double clamp(double val, double min, double max) { if(val < min) return min; else if(val > max) return max; return val; } double constrainAngle(double x) { double sol = std::fmod(x + 180.0, 360.0); if(sol < 0) sol += 360; return sol - 180; } double angleDifference(double final, double initial) { double diff = final - initial; return constrainAngle(diff); } } }