| 89 | } |
| 90 | |
| 91 | bool Math::crossing( |
| 92 | RealVector2D const& segmentStart, |
| 93 | RealVector2D const& segmentEnd, |
| 94 | RealVector2D const& otherSegmentStart, |
| 95 | RealVector2D const& otherSegmentEnd) |
| 96 | { |
| 97 | auto const& p1 = segmentStart; |
| 98 | auto v1 = segmentEnd - segmentStart; |
| 99 | auto const& p2 = otherSegmentStart; |
| 100 | auto v2 = otherSegmentEnd - otherSegmentStart; |
| 101 | |
| 102 | auto divisor = v2.x * v1.y - v2.y * v1.x; |
| 103 | if (abs(divisor) < NEAR_ZERO) { |
| 104 | return false; |
| 105 | } |
| 106 | auto mue = (v1.x * (p2.y - p1.y) - v1.y * (p2.x - p1.x)) / divisor; |
| 107 | if (mue < -NEAR_ZERO || mue > 1 + NEAR_ZERO) { |
| 108 | return false; |
| 109 | } |
| 110 | |
| 111 | float lambda; |
| 112 | if (abs(v1.x) > NEAR_ZERO) { |
| 113 | lambda = (p2.x - p1.x + mue * v2.x) / v1.x; |
| 114 | } else if (abs(v1.y) > NEAR_ZERO) { |
| 115 | lambda = (p2.y - p1.y + mue * v2.y) / v1.y; |
| 116 | } else { |
| 117 | return false; |
| 118 | } |
| 119 | |
| 120 | return lambda >= NEAR_ZERO && lambda <= 1 - NEAR_ZERO; |
| 121 | } |
| 122 | |
| 123 | float Math::modulo(float value, float size) |
| 124 | { |
nothing calls this directly
no outgoing calls
no test coverage detected