diff options
Diffstat (limited to 'src/game/q_math.c')
-rw-r--r-- | src/game/q_math.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/game/q_math.c b/src/game/q_math.c index 9c0e21d7..a23a3456 100644 --- a/src/game/q_math.c +++ b/src/game/q_math.c @@ -1344,6 +1344,31 @@ void PerpendicularVector( vec3_t dst, const vec3_t src ) VectorNormalize( dst ); } +/* +================= +pointToLineDistance + +Distance from a point to some line +================= +*/ +float pointToLineDistance( const vec3_t p0, const vec3_t p1, const vec3_t p2 ) +{ + vec3_t v, w, x, y; + float c1, c2, b; + + VectorSubtract( p2, p1, v ); + VectorSubtract( p1, p0, w ); + + CrossProduct( w, v, y ); + c1 = VectorLength( y ); + c2 = VectorLength( v ); + + if( c2 == 0.0f ) + return 0.0f; + else + return c1 / c2; +} + //TA: wolf trail stuff // Ridah /* |