Gamedev Maths: distance from point to line @SebastianLague
Gamedev Maths: distance from point to line  @SebastianLague
Uploaded June 2017 | Updated September 2026, 2 weeks ago
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: github.com/SebLague/Gamedev-Maths/blob/master/DistanceToLine.cs

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. patreon.com/SebastianLague
paypal.me/SebastianLague
Gamedev Maths: distance from point to lineRPG graphics E05: Run animation [Blender]Introduction to Game Development (E03: Unity overview)[Unity 5] Object Pooling Tutorial[Unity] Procedural Planets (E02 settings editor)Coding Adventure: Marching CubesIntroduction to Game Development (E25: stealth game 3/3)Procedural Landmass Generation (E03: Octaves)[Ludum Dare #43] The Resistance: Behind the ScenesUnity Gradient Editor (2/3)Create an RPG with Unity + Blender (introduction)RPG graphics E08: Icons [Blender]
Sebastian Lague |

Gamedev Maths: distance from point to line

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER