13 #include "simobject.h"
14 #include "arguments.h"
21 extern double GetDistanceBetweenPositions(
const TVector2d* pt_pos1,
const TVector2d* pt_pos2);
22 extern double GetSquaredDistanceBetweenPositions(
const TVector2d* pt_pos1,
const TVector2d* pt_pos2);
25 #define Vec2dLengthSquared(vec) (vec.x*vec.x + vec.y*vec.y)
28 #define Vec2dLength(vec) sqrt(Vec2dLengthSquared(vec))
32 #define Vec2dMultiplyScalar(vec, scalar) \
38 #define Vec2dSub(result, A, B) \
40 result.x = B.x - A.x; \
41 result.y = B.y - A.y; \
45 #define Vec2dAdd(result, A, B) \
47 result.x = B.x + A.x; \
48 result.y = B.y + A.y; \
52 #define Vec2dCosAngle(vec1, vec2) \
53 ((vec1.x * vec2.x + vec1.y * vec2.y) / (Vec2dLength(vec1) * Vec2dLength(vec2)))
56 #define Vec2dAngle(vec1, vec2) \
57 (acos(Vec2dCosAngle(vec1, vec2)))
60 #define Vec2dOwnAngle(vec) \
63 #define Vec2dNormalize(vec) \
65 double length___ = Vec2dLength(vec); \
72 #define NormalizeAngle(ang) \
73 (ang < 0.0 ? fmod(ang, 2.0*M_PI)+2.0*M_PI : fmod(ang, 2.0*M_PI))
76 #define NormalizeAngleNegativePIPositivePI(ang) \
77 (NormalizeAngle(ang) > M_PI ? NormalizeAngle(ang) - 2.0*M_PI : NormalizeAngle(ang))
80 #define Vec2dRotate(angle, vec) \
83 vec.x = cos(angle) * vec.x - sin(angle) * vec.y; \
84 vec.y = cos(angle) * vec.y + sin(angle) * xt_; \
92 #define ERRENDL fprintf(stderr, "\n");
93 #define PRINTPOS(label, vec) printf("%s, x: %2.6f, y: %2.6f\n", label, vec.x, vec.y);
94 #define PRINTVEC2(label, vec) printf("%s, x: %2.6f, y: %2.6f\n", label, vec.x, vec.y);
95 #define FILEANDLINE { fprintf(stderr, "In %s:%d: ", __FILE__, __LINE__); }
96 #define ERROR(s) { FILEANDLINE; fprintf(stderr, s); ERRENDL; }
97 #define ERROR1(s, p1) { FILEANDLINE; fprintf(stderr, s, p1); ERRENDL; }
98 #define ERROR2(s, p1, p2) { FILEANDLINE; fprintf(stderr, s, p1, p2); ERRENDL; }
99 #define ERROR3(s, p1, p2, p3) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3); ERRENDL; }
100 #define ERROR4(s, p1, p2, p3, p4) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4 ); ERRENDL; }
101 #define ERROR5(s, p1, p2, p3, p4, p5) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5 ); ERRENDL; }
102 #define ERROR6(s, p1, p2, p3, p4, p5, p6) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5, p6 ); ERRENDL; }
103 #define ERROR7(s, p1, p2, p3, p4, p5, p6, p7 ) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5, p6, p7 ); ERRENDL; }
104 #define ERROR8(s, p1, p2, p3, p4, p5, p6, p7, p8 ) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5, p6, p7, p8 ); ERRENDL; }
105 #define ERROR9(s, p1, p2, p3, p4, p5, p6, p7, p8, p9 ) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5, p6, p7, p8, p9 ); ERRENDL; }
106 #define ERROR10(s, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ) { FILEANDLINE; fprintf(stderr, s, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 ); ERRENDL; }
113 #define DEBUGOUT(s) { fprintf(stderr, s); }
114 #define DEBUGOUT1(s, p1) { fprintf(stderr, s, p1); }
115 #define DEBUGOUT2(s, p1, p2) { fprintf(stderr, s, p1, p2); }
116 #define DEBUGOUT3(s, p1, p2, p3) { fprintf(stderr, s, p1, p2, p3); }
117 #define DEBUGOUT4(s, p1, p2, p3, p4) { fprintf(stderr, s, p1, p2, p3, p4 ); }
121 #define DEBUGOUT1(s, p1)
122 #define DEBUGOUT2(s, p1, p2)
123 #define DEBUGOUT3(s, p1, p2, p3)
124 #define DEBUGOUT4(s, p1, p2, p3, p4)