29 #include "nomlib/math/helpers.hpp"
33 const double PI = 4.0 * atan ( 1.0 );
35 int32 rand ( int32 start, int32 end )
37 auto seed = std::chrono::system_clock::now().time_since_epoch().count();
38 std::default_random_engine rand_generator ( seed );
39 std::uniform_int_distribution<int32> distribution ( start, end );
41 return distribution ( rand_generator );
44 const Point2d rotate_points (
float angle,
float x,
float y,
float pivot_x,
float pivot_y )
49 float translated_x = 0;
50 float translated_y = 0;
52 float center_x = pivot_x / 2.0f;
53 float center_y = pivot_y / 2.0f;
55 translated_x = x - center_x;
56 translated_y = y - center_y;
58 rotated_x = ( translated_x * cos ( -angle * PI / 180 ) - translated_y * sin ( -angle * PI / 180 ) );
59 rotated_y = ( translated_x * sin ( -angle * PI / 180 ) + translated_y * cos ( -angle * PI / 180 ) );
61 rotated_x += center_x;
62 rotated_y += center_y;
70 double round (
double number )
72 return number < 0.0 ? ceil ( number - 0.5 ) : floor ( number + 0.5 );