Browse Source

added average

Darren Ranalli 21 years ago
parent
commit
432390df8c
1 changed files with 7 additions and 0 deletions
  1. 7 0
      direct/src/showbase/PythonUtil.py

+ 7 - 0
direct/src/showbase/PythonUtil.py

@@ -688,6 +688,13 @@ def lerp(v0, v1, t):
     """
     return v0 + (t * (v1 - v0))
 
+def average(*args):
+    """ returns simple average of list of values """
+    val = 0.
+    for arg in args:
+        val += arg
+    return val / len(args)
+
 def boolEqual(a, b):
     """
     returns true if a and b are both true or both false.