ChirpSim
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros
mathutility.h
Go to the documentation of this file.
1 #pragma once
2 #ifndef MATHUTILITY_H
3 #define MATHUTILITY_H
4 
5 #define DEGTORAD 0.0174532925199432957f
6 #define RADTODEG 57.295779513082320876f
7 #define PI 3.14159265359f
8 
9 #include <QPointF>
10 #include <QList>
11 #include <Box2D/Box2D.h>
12 
18 inline int sign(float x)
19 {
20  if(x > 0) return 1;
21  return (x < 0) ? -1 : 0;
22 }
23 
30 inline float min(float x, float y)
31 {
32  return (x <= y) ? x : y;
33 }
34 
41 inline float max(float x, float y)
42 {
43  return (x > y) ? x : y;
44 }
45 
53 inline float clamp(float x, float minValue, float maxValue)
54 {
55  return min(maxValue, max(minValue, x));
56 }
57 
66 void b2Vec2ToQPointF(b2Vec2* points, size_t num_points, QPointF* result);
67 
75 void QPointFTob2Vec2(QList<QPointF> points, b2Vec2* result);
76 
77 #endif // MATHUTILITY_H