libhomegear-base
0.7
Base library for Homegear and Homegear family modules.
|
#include <Math.h>
Classes | |
class | Line |
Class defining a line. More... | |
class | Matrix3x3 |
Class defining a 3x3 matrix. More... | |
class | Point2D |
Class defining a point in 2D space with numbers of type double. More... | |
class | Point3D |
class | Triangle |
Class defining a triangle. More... | |
Public Types | |
typedef Point2D | Vector2D |
typedef Point3D | Vector3D |
Public Member Functions | |
Math ()=delete | |
~Math ()=default | |
Destructor. More... | |
Static Public Member Functions | |
static bool | isNumber (const std::string &s, bool hex=false) |
Checks if a string is a number. More... | |
static int32_t | getNumber (const std::string &s, bool isHex=false) |
Converts a string (decimal or hexadecimal) to an integer. More... | |
static int64_t | getNumber64 (const std::string &s, bool isHex=false) |
Converts a string (decimal or hexadecimal) to an 64-bit integer. More... | |
static int32_t | getOctalNumber (const std::string &s) |
Converts a octal string to an integer. More... | |
static int32_t | getNumber (char hexChar) |
Converts a hexadecimal character to an integer. More... | |
static uint32_t | getUnsignedNumber (const std::string &s, bool isHex=false) |
Converts a string (decimal or hexadecimal) to an unsigned integer. More... | |
static uint64_t | getUnsignedNumber64 (const std::string &s, bool isHex=false) |
Converts a string (decimal or hexadecimal) to an unsigned integer. More... | |
static uint32_t | getIeee754Binary32 (float value) |
static uint64_t | getIeee754Binary64 (double value) |
static float | getFloatFromIeee754Binary32 (uint32_t binary32) |
static double | getDoubleFromIeee754Binary64 (uint64_t binary64) |
static double | getDouble (const std::string &s) |
Converts a string to double. More... | |
static std::string | toString (double number) |
Converts a double to string removing any trailing zeros. More... | |
static std::string | toString (double number, int32_t precision) |
Converts a double to string. More... | |
static int32_t | clamp (int32_t value, int32_t min, int32_t max) |
Forces a value between 'min' and 'max'. More... | |
static double | clamp (double value, double min, double max) |
Forces a value between 'min' and 'max'. More... | |
static int32_t | scale (int32_t value, int32_t valueMin, int32_t valueMax, int32_t scaleMin, int32_t scaleMax) |
Scales 'value' between 'valueMin' and 'valueMax' to 'scaleMin' and 'scaleMax'. More... | |
static double | scale (double value, double valueMin, double valueMax, double scaleMin, double scaleMax) |
Scales 'value' between 'valueMin' and 'valueMax' to 'scaleMin' and 'scaleMax'. More... | |
static double | Pow10 (int32_t exponent) |
Calculates powers to the base 10. More... | |
static double | metricExponentialMovingAverage (double interval, double period, double metric, double lastAverage) |
Calculates the exponential moving average per time for performance metrics. More... | |
Static Protected Attributes | |
static const std::array< int32_t, 23 > | _asciiToBinaryTable {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, 0, 10, 11, 12, 13, 14, 15} |
Map to faster convert hexadecimal numbers. More... | |
typedef Point2D BaseLib::Math::Vector2D |
typedef Point3D BaseLib::Math::Vector3D |
|
delete |
|
default |
Destructor.
Does nothing.
|
static |
Forces a value between 'min' and 'max'.
If the value is larger than 'max' then it is set to 'max'. If the value is smaller than 'man' it is set to 'min'.
value | The number to clamp. |
min | The lower boundary. |
max | The upper boundary. |
|
static |
Forces a value between 'min' and 'max'.
If the value is larger than 'max' then it is set to 'max'. If the value is smaller than 'man' it is set to 'min'.
value | The number to clamp. |
min | The lower boundary. |
max | The upper boundary. |
|
static |
Converts a string to double.
s | The string to convert to double. |
|
static |
|
static |
|
static |
|
static |
|
static |
Converts a string (decimal or hexadecimal) to an integer.
s | The string to convert. |
isHex | Set this parameter to "true", if the string is hexadecimal (default false). If the string is prefixed with "0x", it is automatically detected as hexadecimal. |
|
static |
Converts a hexadecimal character to an integer.
hexChar | The hexadecimal character. |
|
static |
Converts a string (decimal or hexadecimal) to an 64-bit integer.
s | The string to convert. |
isHex | Set this parameter to "true", if the string is hexadecimal (default false). If the string is prefixed with "0x", it is automatically detected as hexadecimal. |
|
static |
Converts a octal string to an integer.
s | The string to convert. |
|
static |
Converts a string (decimal or hexadecimal) to an unsigned integer.
s | The string to convert. |
isHex | Set this parameter to "true", if the string is hexadecimal (default false). If the string is prefixed with "0x", it is automatically detected as hexadecimal. |
|
static |
Converts a string (decimal or hexadecimal) to an unsigned integer.
s | The string to convert. |
isHex | Set this parameter to "true", if the string is hexadecimal (default false). If the string is prefixed with "0x", it is automatically detected as hexadecimal. |
|
static |
Checks if a string is a number.
s | The string to check. |
hex | (default false) Set to "true" if s contains a hexadecimal number. |
|
static |
Calculates the exponential moving average per time for performance metrics.
interval | The time since the last measurements. The time unit doesn't matter as long as it is the same unit as for period . |
period | The time to average over (e. g. 60 seconds or 15 minutes). The time unit doesn't matter as long as it is the same as for interval . |
metric | The current performance measurement. |
lastAverage | The last output of this method. Pass 0 when this is the first call. |
|
inlinestatic |
Calculates powers to the base 10.
|
static |
Scales 'value' between 'valueMin' and 'valueMax' to 'scaleMin' and 'scaleMax'.
value | The value to scale. |
valueMin | The lowest possible value of 'value'. |
valueMax | The highest possible value of 'value'. |
scaleMin | The lowest value to scale 'value' to. |
scaleMax | The highest value to scale 'value' to. |
|
static |
Scales 'value' between 'valueMin' and 'valueMax' to 'scaleMin' and 'scaleMax'.
value | The value to scale. |
valueMin | The lowest possible value of 'value'. |
valueMax | The highest possible value of 'value'. |
scaleMin | The lowest value to scale 'value' to. |
scaleMax | The highest value to scale 'value' to. |
|
static |
Converts a double to string removing any trailing zeros.
number | The number to convert |
|
static |
Converts a double to string.
number | The number to convert |
precision | The precision |
|
staticprotected |
Map to faster convert hexadecimal numbers.