Colobot
Namespaces | Functions
func.h File Reference

Common math functions. More...

#include "math/const.h"
#include <cmath>
#include <cstdlib>
Include dependency graph for func.h:

Go to the source code of this file.

Namespaces

 Math
 Namespace for (new) math code.
 

Functions

bool Math::IsEqual (float a, float b, float tolerance=Math::TOLERANCE)
 Compares a and b within tolerance. More...
 
bool Math::IsZero (float a, float tolerance=Math::TOLERANCE)
 Compares a to zero within tolerance. More...
 
float Math::Min (float a, float b)
 Minimum. More...
 
float Math::Min (float a, float b, float c)
 
float Math::Min (float a, float b, float c, float d)
 
float Math::Min (float a, float b, float c, float d, float e)
 
float Math::Max (float a, float b)
 Maximum. More...
 
float Math::Max (float a, float b, float c)
 
float Math::Max (float a, float b, float c, float d)
 
float Math::Max (float a, float b, float c, float d, float e)
 
template<typename T >
Math::Clamp (T value, T min, T max)
 Clamps the value to a range specified by min and max. More...
 
float Math::Norm (float a)
 Returns the normalized value (0 .. 1) More...
 
void Math::Swap (int &a, int &b)
 Swaps two integers. More...
 
void Math::Swap (float &a, float &b)
 Swaps two real numbers. More...
 
float Math::Mod (float a, float m)
 Returns the modulo of a floating point number. More...
 
float Math::Rand ()
 Returns a random value between 0 and 1. More...
 
bool Math::IsPowerOfTwo (unsigned int x)
 Returns whether x is an even power of 2. More...
 
int Math::NextPowerOfTwo (int x)
 Returns the next nearest power of two to x. More...
 
float Math::NormAngle (float angle)
 Returns a normalized angle, that is in other words between 0 and 2 * PI. More...
 
bool Math::TestAngle (float angle, float min, float max)
 Test if a angle is between two terminals. More...
 
float Math::PropAngle (float a, float b, float p)
 Calculates a value (radians) proportional between a and b (degrees) More...
 
float Math::Direction (float a, float g)
 Calculates the angle to rotate the angle a to the angle g. More...
 
float Math::Neutral (float value, float dead)
 Managing the dead zone of a joystick. More...
 
float Math::Smooth (float actual, float hope, float time)
 Gently advances a desired value from its current value. More...
 
float Math::Bounce (float progress, float middle=0.3f, float bounce=0.4f)
 Bounces any movement. More...
 

Detailed Description

Common math functions.