returns intersection point of (a->b)x(c->d) nullopt if parallel
| 182 | // returns intersection point of (a->b)x(c->d) |
| 183 | // nullopt if parallel |
| 184 | std::optional<Vector2f> findIntersection( const Vector2f& a, const Vector2f& b, const Vector2f& c, const Vector2f& d ) |
| 185 | { |
| 186 | auto vecA = b - a; |
| 187 | if ( cross( vecA, d - c ) == 0.0f ) |
| 188 | return std::nullopt; |
| 189 | |
| 190 | auto abcS = cross( c - a, vecA ); |
| 191 | auto abdS = cross( vecA, d - a ); |
| 192 | |
| 193 | auto sum = abcS + abdS; |
| 194 | if ( sum == 0.0f ) |
| 195 | return std::nullopt; |
| 196 | auto ratio = abcS / sum; |
| 197 | return c * ( 1.0f - ratio ) + d * ratio; |
| 198 | } |
| 199 | |
| 200 | void insertRoundCorner( Contour2f& cont, const CornerParameters& params, float minAnglePrecision, int* shiftMap ) |
| 201 | { |
no test coverage detected