|
21 | 21 | #define RECT_H
|
22 | 22 |
|
23 | 23 | #include <algorithm> // for std::max, std::min
|
24 |
| -#include <cmath> // for ceil, floor |
| 24 | +#include <cmath> // for std::ceil, std::floor |
25 | 25 | #include <cstdint> // for INT16_MAX
|
26 | 26 | #include <cstdio> // for FILE
|
27 | 27 | #include "platform.h" // for DLLSYM
|
@@ -162,29 +162,33 @@ class DLLSYM TBOX { // bounding box
|
162 | 162 |
|
163 | 163 | void move( // move box
|
164 | 164 | const FCOORD vec) { // by float vector
|
165 |
| - bot_left.set_x ((int16_t) floor (bot_left.x () + vec.x ())); |
| 165 | + bot_left.set_x(static_cast<int16_t>(std::floor(bot_left.x() + vec.x()))); |
166 | 166 | // round left
|
167 |
| - bot_left.set_y ((int16_t) floor (bot_left.y () + vec.y ())); |
| 167 | + bot_left.set_y(static_cast<int16_t>(std::floor(bot_left.y() + vec.y()))); |
168 | 168 | // round down
|
169 |
| - top_right.set_x ((int16_t) ceil (top_right.x () + vec.x ())); |
| 169 | + top_right.set_x(static_cast<int16_t>(std::ceil(top_right.x() + vec.x()))); |
170 | 170 | // round right
|
171 |
| - top_right.set_y ((int16_t) ceil (top_right.y () + vec.y ())); |
| 171 | + top_right.set_y(static_cast<int16_t>(std::ceil(top_right.y() + vec.y()))); |
172 | 172 | // round up
|
173 | 173 | }
|
174 | 174 |
|
175 | 175 | void scale( // scale box
|
176 | 176 | const float f) { // by multiplier
|
177 |
| - bot_left.set_x ((int16_t) floor (bot_left.x () * f)); // round left |
178 |
| - bot_left.set_y ((int16_t) floor (bot_left.y () * f)); // round down |
179 |
| - top_right.set_x ((int16_t) ceil (top_right.x () * f)); // round right |
180 |
| - top_right.set_y ((int16_t) ceil (top_right.y () * f)); // round up |
| 177 | + // round left |
| 178 | + bot_left.set_x(static_cast<int16_t>(std::floor(bot_left.x() * f))); |
| 179 | + // round down |
| 180 | + bot_left.set_y(static_cast<int16_t>(std::floor(bot_left.y() * f))); |
| 181 | + // round right |
| 182 | + top_right.set_x(static_cast<int16_t>(std::ceil(top_right.x() * f))); |
| 183 | + // round up |
| 184 | + top_right.set_y(static_cast<int16_t>(std::ceil(top_right.y() * f))); |
181 | 185 | }
|
182 | 186 | void scale( // scale box
|
183 | 187 | const FCOORD vec) { // by float vector
|
184 |
| - bot_left.set_x ((int16_t) floor (bot_left.x () * vec.x ())); |
185 |
| - bot_left.set_y ((int16_t) floor (bot_left.y () * vec.y ())); |
186 |
| - top_right.set_x ((int16_t) ceil (top_right.x () * vec.x ())); |
187 |
| - top_right.set_y ((int16_t) ceil (top_right.y () * vec.y ())); |
| 188 | + bot_left.set_x(static_cast<int16_t>(std::floor(bot_left.x() * vec.x()))); |
| 189 | + bot_left.set_y(static_cast<int16_t>(std::floor(bot_left.y() * vec.y()))); |
| 190 | + top_right.set_x(static_cast<int16_t>(std::ceil(top_right.x() * vec.x()))); |
| 191 | + top_right.set_y(static_cast<int16_t>(std::ceil(top_right.y() * vec.y()))); |
188 | 192 | }
|
189 | 193 |
|
190 | 194 | // rotate doesn't enlarge the box - it just rotates the bottom-left
|
@@ -314,8 +318,10 @@ class DLLSYM TBOX { // bounding box
|
314 | 318 | inline TBOX::TBOX( // constructor
|
315 | 319 | const FCOORD pt // floating centre
|
316 | 320 | ) {
|
317 |
| - bot_left = ICOORD ((int16_t) floor (pt.x ()), (int16_t) floor (pt.y ())); |
318 |
| - top_right = ICOORD ((int16_t) ceil (pt.x ()), (int16_t) ceil (pt.y ())); |
| 321 | + bot_left = ICOORD(static_cast<int16_t>(std::floor(pt.x())), |
| 322 | + static_cast<int16_t>(std::floor(pt.y()))); |
| 323 | + top_right = ICOORD(static_cast<int16_t>(std::ceil(pt.x())), |
| 324 | + static_cast<int16_t>(std::ceil(pt.y()))); |
319 | 325 | }
|
320 | 326 |
|
321 | 327 |
|
|
0 commit comments