| 2320 | // optionally returns collision point and collision normal of ray and a line segment, if it collides |
| 2321 | template<typename T1, typename T2> |
| 2322 | inline std::optional<std::pair<olc::v_2d<T2>, olc::v_2d<T2>>> collision(const ray<T1>& q, const line<T2>& l) |
| 2323 | { |
| 2324 | const auto vIntersection = intersects(q, l); |
| 2325 | if (vIntersection.size() > 0) |
| 2326 | { |
| 2327 | return { {vIntersection[0], l.vector().perp().norm() * l.side(q.origin)} }; |
| 2328 | } |
| 2329 | |
| 2330 | return std::nullopt; |
| 2331 | } |
| 2332 | |
| 2333 | // reflect(q,l) |
| 2334 | // optionally returns a ray reflected off a line segement if collision occurs |
no test coverage detected