Skip to content

Instantly share code, notes, and snippets.

@kim366
Created June 15, 2018 13:03
Show Gist options
  • Save kim366/5ac190f257d1407d20ad88631f92ef25 to your computer and use it in GitHub Desktop.
Save kim366/5ac190f257d1407d20ad88631f92ef25 to your computer and use it in GitHub Desktop.
sf::Vector2f put_point_on_line(sf::Vector2f point, sf::Vector2f line_point0, sf::Vector2f line_point1)
{
const sf::Vector2f line_seg{line_point1 - line_point0};
return line_point1 + unitV(line_seg) * dot(unitV(line_seg), point - line_point1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment