Returns line equation "mx + a" coefficients where: x: m y: a NOTE: Returns {inf, inf} if std::abs(end.x - start.x) < epsilon:
| 616 | // y: a |
| 617 | // NOTE: Returns {inf, inf} if std::abs(end.x - start.x) < epsilon: |
| 618 | inline constexpr olc::vd2d coefficients() const |
| 619 | { |
| 620 | double x1 = start.x; |
| 621 | double x2 = end.x; |
| 622 | double y1 = start.y; |
| 623 | double y2 = end.y; |
| 624 | |
| 625 | // check if line is vertical or close to vertical |
| 626 | if (std::abs(x2 - x1) < epsilon) { |
| 627 | return olc::vd2d{ std::numeric_limits<double>::infinity(), std::numeric_limits<double>::infinity() }; |
| 628 | } |
| 629 | |
| 630 | double m = (y2 - y1) / (x2 - x1); |
| 631 | return olc::vd2d{ m, -m * x1 + y1 }; |
| 632 | } |
| 633 | }; |
| 634 | |
| 635 | template<typename T> |
nothing calls this directly
no outgoing calls
no test coverage detected