Last active
November 22, 2017 16:39
-
-
Save pavel-perina/0e7e6716385485d9a4fee7c296300eb7 to your computer and use it in GitHub Desktop.
C/C++ code snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------------------------- | |
/// @brief Difference between two angles in radians, difference is inside -PI..PI | |
/// @todo: verify sign | |
/// NOTE: same function in Collision\col_math.cpp | |
__inline double AngleDiffRad (double a, double b) | |
{ | |
double r = fmod (b - a, M_PI+M_PI); | |
if (r < 0.0) | |
r += M_PI+M_PI; | |
if (r > M_PI) | |
r -= M_PI+M_PI; | |
return -r; | |
} | |
// ----------------------------------------------------------------------------------- | |
/// Difference between two angles in degrees, difference is inside -180..180 | |
__inline double AngleDiffDeg (double a, double b) | |
{ | |
double r = fmod (b - a, 360.0); | |
if (r < 0.0) | |
r += 360.0; | |
if (r > 180.0) | |
r -= 360.0; | |
return -r; | |
} | |
// ----------------------------------------------------------------------------------- | |
#ifdef PROFILE_COLLISION_TEST_TIME | |
std::chrono::time_point<std::chrono::system_clock> start = std::chrono::system_clock::now(); | |
#endif | |
colResult = pCollTest->checkCollision(trajectory, abortCheckFunc); | |
#ifdef PROFILE_COLLISION_TEST_TIME | |
std::chrono::duration<double, std::ratio<1, 1000>> durationMili = std::chrono::system_clock::now() - start; | |
qDebug() << "Checked " << QString::number(trajectory.size()) << " trajectory points took " << QString::number(durationMili.count()) << " ms"; | |
#endif | |
// ----------------------------------------------------------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment