From 6c1109ac122cf9a9da1c0f1f15af2a618a189541 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Mon, 24 Jun 2002 23:13:59 +0000 Subject: Better off3u directzap --- src/game/q_math.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/game/q_math.c') 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 /* -- cgit