summaryrefslogtreecommitdiff
path: root/src/game/q_math.c
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2002-06-24 23:13:59 +0000
committerTim Angus <tim@ngus.net>2002-06-24 23:13:59 +0000
commit6c1109ac122cf9a9da1c0f1f15af2a618a189541 (patch)
tree54c09cf868f634104583b33514b8f0bc795fd63a /src/game/q_math.c
parentc90c76a68d8b9af8951b5f2110e1eac6fbec3702 (diff)
Better off3u directzap
Diffstat (limited to 'src/game/q_math.c')
-rw-r--r--src/game/q_math.c25
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
/*