Gamedev Maths: distance from point to line

Описание к видео Gamedev Maths: distance from point to line

In this video we determine an equation for the shortest distance between some point C, and the line passing through points A and B.
The equation is: dst = abs((C.x-A.x) * (-B.y+A.y) + (C.y-A.y) * (B.x-A.x)) / sqrt((-B.y+A.y)^2 + (B.x-A.x)^2)

We also see how this equation can be modified to determine if two points lie on the same side of a line.
C# code for the equations can be found here: https://github.com/SebLague/Gamedev-M...

If you'd like to support these videos, you can do so with a recurring pledge on Patreon, or a one-time donation through PayPal.   / sebastianlague  
https://www.paypal.me/SebastianLague

Комментарии

Информация по комментариям в разработке