Try my new website: www.urcho.com - the new SIMPLE social network
blitz code snippets Sign up | 287 members | 114 snippets
Search for:

Username:
Password:


Point distance to a Line by Danny

[back]
Author: Archive | Viewed: 647 times | Language: BlitzBasic 3D | Category: Maths/Physics
Author Comments:
Given 2 3d points A and B (that make up for a line-segment) and a point P; this function will return the shortest distance between that point P and the line. I use this for my vertex lighting system where I have a linear light (a light defined by 2 3d coordinates) to check if a vertex (point P) is within range of that light, and its distance determines its fall-off. You could also use this to determin if the player is too close to a laser beam for example (or some other linear-object) like: IF player-distance-to-line <= heath-range-of-beam THEN add damage to player :) Danny
Login or create an account to comment on this snippet