Compute the direction of a segment
| 39 | { |
| 40 | // Compute the direction of a segment |
| 41 | sf::Vector2f computeDirection(sf::Vector2f p1, sf::Vector2f p2) |
| 42 | { |
| 43 | sf::Vector2f direction = p2 - p1; |
| 44 | const float length = direction.length(); |
| 45 | if (length != 0.f) |
| 46 | direction /= length; |
| 47 | return direction; |
| 48 | } |
| 49 | } // namespace |
| 50 | |
| 51 |