|
|
|
@ -108,7 +108,7 @@ struct Vector2
@@ -108,7 +108,7 @@ struct Vector2
|
|
|
|
|
|
|
|
|
|
// check if all elements are zero
|
|
|
|
|
bool is_zero(void) const WARN_IF_UNUSED { |
|
|
|
|
return (fabsf(x) < FLT_EPSILON) && (fabsf(y) < FLT_EPSILON); |
|
|
|
|
return x == 0 && y == 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// allow a vector2 to be used as an array, 0 indexed
|
|
|
|
@ -242,14 +242,14 @@ struct Vector2
@@ -242,14 +242,14 @@ struct Vector2
|
|
|
|
|
const T expected_run = seg_end.x-seg_start.x; |
|
|
|
|
const T intersection_run = point.x-seg_start.x; |
|
|
|
|
// check slopes are identical:
|
|
|
|
|
if (fabsf(expected_run) < FLT_EPSILON) { |
|
|
|
|
if (fabsf(intersection_run) > FLT_EPSILON) { |
|
|
|
|
if (::is_zero(expected_run)) { |
|
|
|
|
if (fabsF(intersection_run) > FLT_EPSILON) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
const T expected_slope = (seg_end.y-seg_start.y)/expected_run; |
|
|
|
|
const T intersection_slope = (point.y-seg_start.y)/intersection_run; |
|
|
|
|
if (fabsf(expected_slope - intersection_slope) > FLT_EPSILON) { |
|
|
|
|
if (fabsF(expected_slope - intersection_slope) > FLT_EPSILON) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -276,6 +276,15 @@ struct Vector2
@@ -276,6 +276,15 @@ struct Vector2
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// check if all elements are zero
|
|
|
|
|
template<> inline bool Vector2<float>::is_zero(void) const { |
|
|
|
|
return ::is_zero(x) && ::is_zero(y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
template<> inline bool Vector2<double>::is_zero(void) const { |
|
|
|
|
return ::is_zero(x) && ::is_zero(y); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
typedef Vector2<int16_t> Vector2i; |
|
|
|
|
typedef Vector2<uint16_t> Vector2ui; |
|
|
|
|
typedef Vector2<int32_t> Vector2l; |
|
|
|
|