swift
Loading...
Searching...
No Matches
swift::misc::physical_quantities::CMathUtils Class Reference

Math utils. More...

#include <mathutils.h>

Public Member Functions

 CMathUtils ()=delete
 No objects, just static.

Static Public Member Functions

static double round (double value, int digits)
 Utility round method.
static double roundEpsilon (double value, double epsilon)
 Round by given epsilon.
static double trunc (double value, double epsilon=1e-10)
 Nearest integer not greater in magnitude than value, correcting for epsilon.
static double fract (double value)
 Fractional part of value.
static double deg2rad (double degree)
 Degrees to radians.
static double rad2deg (double radians)
 Radians to degrees.
static double normalizeDegrees180 (double degrees)
 Normalize: -180< degrees ≤180.
static double normalizeDegrees360 (double degrees)
 Normalize: 0≤ degrees <360.
static QRandomGenerator & randomGenerator ()
 Thread-local random generator.
static int randomInteger (int low, int high)
 Random number between low and high.
static double randomDouble (double max=1)
 Random double 0-max.
static bool randomBool ()
 Random boolean.
static int roundToMultipleOf (int value, int divisor)
 Round numToRound to the nearest multiple of divisor.
static QString fractionalPartAsString (double value, int width=-1)
 Fractional part as integer string, e.g. 3.12 -> 12 / 3.012 -> 012.
static double sum (const QList< double > &values)
 Calculate the sum.
static double mean (const QList< double > &values)
 Calculate the mean.
static double standardDeviation (const QList< double > &values)
 Calculate the standard deviation.
static QPair< double, double > standardDeviationAndMean (const QList< double > &values)
 Standard deviation (first) and mean (second).
static bool epsilonEqual (float v1, float v2, float epsilon=1E-06f)
 Epsilon safe equal.
static bool epsilonEqual (double v1, double v2, double epsilon=1E-06)
 Epsilon safe equal.
static bool epsilonEqualLimits (double v1, double v2)
 Epsilon safe equal.
static bool epsilonZero (double v, double epsilon)
 Epsilon safe zero.
static bool epsilonZero (double v)
 Epsilon safe zero.
static bool epsilonZeroLimits (double v)
 Epsilon safe zero.

Detailed Description

Math utils.

Definition at line 22 of file mathutils.h.

Member Function Documentation

◆ deg2rad()

double swift::misc::math::CMathUtils::deg2rad ( double degree)
static

Degrees to radians.

Definition at line 55 of file mathutils.cpp.

◆ epsilonEqual() [1/2]

bool swift::misc::math::CMathUtils::epsilonEqual ( double v1,
double v2,
double epsilon = 1E-06 )
static

Epsilon safe equal.

Definition at line 53 of file mathutils.cpp.

◆ epsilonEqual() [2/2]

bool swift::misc::math::CMathUtils::epsilonEqual ( float v1,
float v2,
float epsilon = 1E-06f )
static

Epsilon safe equal.

Definition at line 51 of file mathutils.cpp.

◆ epsilonEqualLimits()

bool swift::misc::math::CMathUtils::epsilonEqualLimits ( double v1,
double v2 )
inlinestatic

Epsilon safe equal.

Definition at line 38 of file mathutils.h.

◆ epsilonZero() [1/2]

bool swift::misc::math::CMathUtils::epsilonZero ( double v)
inlinestatic

Epsilon safe zero.

Definition at line 47 of file mathutils.h.

◆ epsilonZero() [2/2]

bool swift::misc::math::CMathUtils::epsilonZero ( double v,
double epsilon )
inlinestatic

Epsilon safe zero.

Definition at line 46 of file mathutils.h.

◆ epsilonZeroLimits()

bool swift::misc::math::CMathUtils::epsilonZeroLimits ( double v)
inlinestatic

Epsilon safe zero.

Definition at line 48 of file mathutils.h.

◆ fract()

double swift::misc::math::CMathUtils::fract ( double value)
inlinestatic

Fractional part of value.

Definition at line 58 of file mathutils.h.

◆ fractionalPartAsString()

QString swift::misc::math::CMathUtils::fractionalPartAsString ( double value,
int width = -1 )
static

Fractional part as integer string, e.g. 3.12 -> 12 / 3.012 -> 012.

Remarks
because of leading 0 returned as string

Definition at line 111 of file mathutils.cpp.

◆ mean()

double swift::misc::math::CMathUtils::mean ( const QList< double > & values)
static

Calculate the mean.

Definition at line 156 of file mathutils.cpp.

◆ normalizeDegrees180()

double swift::misc::math::CMathUtils::normalizeDegrees180 ( double degrees)
static

Normalize: -180< degrees ≤180.

Definition at line 59 of file mathutils.cpp.

◆ normalizeDegrees360()

double swift::misc::math::CMathUtils::normalizeDegrees360 ( double degrees)
static

Normalize: 0≤ degrees <360.

Definition at line 65 of file mathutils.cpp.

◆ rad2deg()

double swift::misc::math::CMathUtils::rad2deg ( double radians)
static

Radians to degrees.

Definition at line 57 of file mathutils.cpp.

◆ randomBool()

Random boolean.

Definition at line 90 of file mathutils.cpp.

◆ randomDouble()

double swift::misc::math::CMathUtils::randomDouble ( double max = 1)
static

Random double 0-max.

Definition at line 83 of file mathutils.cpp.

◆ randomGenerator()

Thread-local random generator.

Definition at line 71 of file mathutils.cpp.

◆ randomInteger()

int swift::misc::math::CMathUtils::randomInteger ( int low,
int high )
static

Random number between low and high.

Definition at line 77 of file mathutils.cpp.

◆ round()

double swift::misc::math::CMathUtils::round ( double value,
int digits )
static

Utility round method.

Definition at line 18 of file mathutils.cpp.

◆ roundEpsilon()

double swift::misc::math::CMathUtils::roundEpsilon ( double value,
double epsilon )
static

Round by given epsilon.

Definition at line 33 of file mathutils.cpp.

◆ roundToMultipleOf()

int swift::misc::math::CMathUtils::roundToMultipleOf ( int value,
int divisor )
static

Round numToRound to the nearest multiple of divisor.

Definition at line 92 of file mathutils.cpp.

◆ standardDeviation()

double swift::misc::math::CMathUtils::standardDeviation ( const QList< double > & values)
static

Calculate the standard deviation.

Definition at line 168 of file mathutils.cpp.

◆ standardDeviationAndMean()

QPair< double, double > swift::misc::math::CMathUtils::standardDeviationAndMean ( const QList< double > & values)
static

Standard deviation (first) and mean (second).

Definition at line 174 of file mathutils.cpp.

◆ sum()

double swift::misc::math::CMathUtils::sum ( const QList< double > & values)
static

Calculate the sum.

Definition at line 129 of file mathutils.cpp.

◆ trunc()

double swift::misc::math::CMathUtils::trunc ( double value,
double epsilon = 1e-10 )
inlinestatic

Nearest integer not greater in magnitude than value, correcting for epsilon.

Definition at line 52 of file mathutils.h.


The documentation for this class was generated from the following files: