/** * @file * * @author Max Lammers * @author Mamadou Babaei * * @section LICENSE * * Copyright (c) 2020 - 2022 SenseGlove * * @section DESCRIPTION * * Utility class to process and convert values in different formats. */ #pragma once #include #include #include "Platform.hpp" namespace SGCore { namespace Kinematics { class Quat; /// Utility class to convert values into various formats. class SGCORE_API Values; class Vect3D; }// namespace Kinematics }// namespace SGCore /// Utility class to convert values into various formats. class SGCORE_API SGCore::Kinematics::Values { public: /// Converts degrees into radians. static float DegreesToRadians(); /// Converts radians into degrees. static float RadiansToDegrees(); /// 2*PI is used frequently in angle normalization. static float Get2PI(); public: /// Convert a vector of degrees angles into radians. static Vect3D Radians(const Vect3D& degrees); /// Convert a vector of radian angles into degrees. static Vect3D Degrees(const Vect3D& radians); /// Ensure that a single angle is within the [-Pi...Pi] range. static float NormalizeAngle(float angle, float minAngle, float maxAngle); /// Normalize and angle between a variable range. static float NormalizeAngle(float angle); /// Normalize a set of angles in radians. static Vect3D NormalizeAngles(const Vect3D& angles); /// Ensure that a value remains within the [min...max] range. static float Clamp(float value, float min, float max); /// Ensure that an integer value remains within the [min...max] range. static int32_t Clamp(int32_t value, int32_t min, int32_t max); /// Map a value from one range [from1...from2] to another range [to1 .. to2] static float Map(float value, float from1, float from2, float to1, float to2); /// Map a value from one range [from1...from2] to another range [to1 .. to2], /// while ensuring it stays within the [min...max] range. static float Map(float value, float from1, float from2, float to1, float to2, float min, float max); /// Check if two floating points are roughly equal, taking into account the minor differences. static bool FloatEquals(float valueA, float valueB); /// Check if two arrays contain equal values. static bool Equal(const std::vector& arrayA, const std::vector& arrayB); /// Check if two arrays contain equal values. static bool Equal(const std::vector>& arrayA, const std::vector>& arrayB); /// Check if two arrays contain equal values. static bool Equal(const std::vector& arrayA, const std::vector& arrayB); /// Check if two arrays contain equal values. static bool Equal(const std::vector>& arrayA, const std::vector>& arrayB); /// Returns an array of Vect3D's, all at 0, 0, 0. Used for quick generation and to avoid NullRefs /// /// static std::vector FillZero(int32_t length); /// Returns a 2D of Vect3D's [Length, Width] all at 0, 0, 0. Used for quick generation and to avoid NullRefs /// /// /// static std::vector> FillZero(int32_t length, int32_t width); public: Values() = delete; virtual ~Values() = delete; };