initial version
This commit is contained in:
33
geo/Angle.h
Executable file
33
geo/Angle.h
Executable file
@@ -0,0 +1,33 @@
|
||||
#ifndef ANGLE_H
|
||||
#define ANGLE_H
|
||||
|
||||
#include <cmath>
|
||||
|
||||
class Angle {
|
||||
|
||||
public:
|
||||
|
||||
/** get the radians from (x1,y1) to (x2,y2) */
|
||||
static float getRAD(const float x1, const float y1, const float x2, const float y2) {
|
||||
const float tmp = std::atan2(y2-y1, x2-x1);
|
||||
return (tmp < 0) ? (tmp + 2*M_PI) : (tmp);
|
||||
}
|
||||
|
||||
/** get the degrees from (x1,y1) to (x2,y2) */
|
||||
static float getDEG(const float x1, const float y1, const float x2, const float y2) {
|
||||
return radToDeg(getRAD(x1,y1,x2,y2));
|
||||
}
|
||||
|
||||
/** convert degrees to radians */
|
||||
static float degToRad(const float deg) {
|
||||
return deg / 180 * M_PI;
|
||||
}
|
||||
|
||||
/** convert radians to degrees */
|
||||
static float radToDeg(const float rad) {
|
||||
return rad * 180 / M_PI;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // ANGLE_H
|
||||
21
geo/Line2D.h
Executable file
21
geo/Line2D.h
Executable file
@@ -0,0 +1,21 @@
|
||||
#ifndef LINE2D_H
|
||||
#define LINE2D_H
|
||||
|
||||
#include <KLib/geo/Line.h>
|
||||
|
||||
class Line2D : public K::Line {
|
||||
|
||||
public:
|
||||
|
||||
Line2D() : K::Line() {;}
|
||||
|
||||
Line2D(const float x1, const float y1, const float x2, const float y2) : K::Line(x1,y1,x2,y2) {;}
|
||||
|
||||
bool getSegmentIntersection(const Line& other) const {
|
||||
static K::Point p;
|
||||
return K::Line::getSegmentIntersection(other, p);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // LINE2D_H
|
||||
16
geo/Units.h
Executable file
16
geo/Units.h
Executable file
@@ -0,0 +1,16 @@
|
||||
#ifndef UNITS_H
|
||||
#define UNITS_H
|
||||
|
||||
class Units {
|
||||
|
||||
public:
|
||||
|
||||
/** convert from m to cm */
|
||||
template <typename T> static inline T mToCm(const T m) {return m * 100;}
|
||||
|
||||
/** convert from cm to m */
|
||||
template <typename T> static inline T cmToM(const T cm) {return cm / 100;}
|
||||
|
||||
};
|
||||
|
||||
#endif // UNITS_H
|
||||
Reference in New Issue
Block a user