1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 07:07:45 +00:00
sapphire/src/common/Util/UtilMath.h

49 lines
872 B
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef _UTILMATH_H
#define _UTILMATH_H
#include <common/Common.h>
2017-08-08 13:53:47 +02:00
#define PI 3.14159265358979323846f
namespace Core {
namespace Math {
namespace Util {
float distanceSq( float x, float y, float z, float x1, float y1, float z1 );
float distance( float x, float y, float z, float x1, float y1, float z1 );
float distance2DSq( float x, float y, float x1, float y1 );
float distance2D( float x, float y, float x1, float y1 );
float calcAngTo( float x, float y, float x1, float y1 );
float calcAngFrom( float x, float y, float x1, float y1 );
uint16_t floatToUInt16( float val );
uint16_t floatToUInt16Rot( float val );
uint8_t floatToUInt8Rot( float val );
template
<typename T>
T clamp( T val, T minimum, T maximum )
{
2017-08-08 21:01:09 +09:00
if (val > maximum)
{
return maximum;
}
if (val < minimum)
{
return minimum;
}
return val;
2017-08-08 13:53:47 +02:00
}
}
}
}
2017-08-08 14:25:04 +02:00
#endif