]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - libs/mathlib/mathlib.c
Rewriting BaseWindingForPlane() in polylib.c from the ground up. The behavior
[xonotic/netradiant.git] / libs / mathlib / mathlib.c
index 33945cde4ed22436a696c2942e6998c70f954d9c..1234a86f7452bd635affc89d8f9342e0e6defb58 100644 (file)
@@ -143,6 +143,21 @@ vec_t VectorNormalize( const vec3_t in, vec3_t out ) {
        return length;
 }
 
        return length;
 }
 
+vec_t VectorSetLength(const vec3_t in, vec_t length, vec3_t out) {
+       vec_t   origLength;
+
+       origLength = (vec_t) sqrt((in[0] * in[0]) + (in[1] * in[1]) + (in[2] * in[2]));
+       if (origLength == 0)
+       {
+               VectorClear(out);
+               return 0;
+       }
+
+       VectorScale(in, length / origLength, out);
+
+       return origLength;
+}
+
 vec_t ColorNormalize( const vec3_t in, vec3_t out ) {
        float   max, scale;
 
 vec_t ColorNormalize( const vec3_t in, vec3_t out ) {
        float   max, scale;