MCPcopy Create free account
hub / github.com/csaez/mscreen / bezierInterpolate

Function bezierInterpolate

mscreen.py:700–719  ·  view source on GitHub ↗

Performs a bezier interpolation (recursive).

(t, points)

Source from the content-addressed store, hash-verified

698
699
700def bezierInterpolate(t, points):
701 """
702 Performs a bezier interpolation (recursive).
703 """
704 if not _isIterable(points):
705 logger.error('Points is expected to be a secuence of points')
706 return
707 n = len(points) - 1
708 n_factorial = math.factorial(n)
709 for i, p in enumerate(points):
710 if not isinstance(p, om2.MVector):
711 p = om2.MVector(p)
712 k = n_factorial / float(math.factorial(i) * math.factorial(n - i))
713 b = (t**i) * (1 - t)**(n - i)
714 v = p * b * k
715 if i == 0:
716 rval = v
717 else:
718 rval += v
719 return rval
720
721# === Accessors ===
722_scn = SceneManager() # singleton

Callers 1

updateMethod · 0.85

Calls 1

_isIterableFunction · 0.85

Tested by

no test coverage detected