|
|
|
@ -43,19 +43,16 @@ bool Polygon_outside(const Vector2<T> &P, const Vector2<T> *V, unsigned n)
@@ -43,19 +43,16 @@ bool Polygon_outside(const Vector2<T> &P, const Vector2<T> *V, unsigned n)
|
|
|
|
|
if ((V[i].y > P.y) == (V[j].y > P.y)) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
int32_t dx1, dx2, dy1, dy2; |
|
|
|
|
dx1 = P.x - V[i].x; |
|
|
|
|
dx2 = V[j].x - V[i].x; |
|
|
|
|
dy1 = P.y - V[i].y; |
|
|
|
|
dy2 = V[j].y - V[i].y; |
|
|
|
|
int8_t dx1s, dx2s, dy1s, dy2s, m1, m2; |
|
|
|
|
#define sign(x) ((x)<0 ? -1 : 1) |
|
|
|
|
dx1s = sign(dx1); |
|
|
|
|
dx2s = sign(dx2); |
|
|
|
|
dy1s = sign(dy1); |
|
|
|
|
dy2s = sign(dy2); |
|
|
|
|
m1 = dx1s * dy2s; |
|
|
|
|
m2 = dx2s * dy1s; |
|
|
|
|
const int32_t dx1 = P.x - V[i].x; |
|
|
|
|
const int32_t dx2 = V[j].x - V[i].x; |
|
|
|
|
const int32_t dy1 = P.y - V[i].y; |
|
|
|
|
const int32_t dy2 = V[j].y - V[i].y; |
|
|
|
|
const int8_t dx1s = (dx1 < 0) ? -1 : 1; |
|
|
|
|
const int8_t dx2s = (dx2 < 0) ? -1 : 1; |
|
|
|
|
const int8_t dy1s = (dy1 < 0) ? -1 : 1; |
|
|
|
|
const int8_t dy2s = (dy2 < 0) ? -1 : 1; |
|
|
|
|
const int8_t m1 = dx1s * dy2s; |
|
|
|
|
const int8_t m2 = dx2s * dy1s; |
|
|
|
|
// we avoid the 64 bit multiplies if we can based on sign checks.
|
|
|
|
|
if (dy2 < 0) { |
|
|
|
|
if (m1 > m2) { |
|
|
|
|