[nexuiz-commits] r8219 - trunk/data/qcsrc/common

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Fri Nov 6 14:56:01 EST 2009


Author: div0
Date: 2009-11-06 14:56:01 -0500 (Fri, 06 Nov 2009)
New Revision: 8219

Modified:
   trunk/data/qcsrc/common/util.qc
   trunk/data/qcsrc/common/util.qh
Log:
float2range11 :P


Modified: trunk/data/qcsrc/common/util.qc
===================================================================
--- trunk/data/qcsrc/common/util.qc	2009-11-06 19:44:36 UTC (rev 8218)
+++ trunk/data/qcsrc/common/util.qc	2009-11-06 19:56:01 UTC (rev 8219)
@@ -1651,11 +1651,14 @@
 #endif
 #endif
 
+float float2range11(float f)
+{
+	// continuous function mapping all reals into -1..1
+	return f / (fabs(f) + 1);
+}
+
 float float2range01(float f)
 {
 	// continuous function mapping all reals into 0..1
-	if(f >= 0)
-		return 1.0 - 0.5 / (1.0 + f);
-	else
-		return 0.0 + 0.5 / (1.0 - f);
+	return 0.5 + 0.5 * float2range11(f);
 }

Modified: trunk/data/qcsrc/common/util.qh
===================================================================
--- trunk/data/qcsrc/common/util.qh	2009-11-06 19:44:36 UTC (rev 8218)
+++ trunk/data/qcsrc/common/util.qh	2009-11-06 19:56:01 UTC (rev 8219)
@@ -198,4 +198,5 @@
 // the NULL function
 const var void func_null(void);
 const var string string_null;
+float float2range11(float f);
 float float2range01(float f);



More information about the nexuiz-commits mailing list