mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Update to bezier
This commit is contained in:
parent
7b0b31e8d9
commit
596aea3bf5
1 changed files with 4 additions and 1 deletions
|
@ -24,9 +24,12 @@ CLOSED_THRESHOLD = 0.001
|
||||||
def bezier(
|
def bezier(
|
||||||
points: Sequence[Scalable]
|
points: Sequence[Scalable]
|
||||||
) -> Callable[[float], Scalable]:
|
) -> Callable[[float], Scalable]:
|
||||||
|
if len(points) == 0:
|
||||||
|
raise Exception("bezier cannot be calld on an empty list")
|
||||||
|
|
||||||
n = len(points) - 1
|
n = len(points) - 1
|
||||||
|
|
||||||
def result(t: Scalable) -> Scalable:
|
def result(t: float) -> Scalable:
|
||||||
return sum(
|
return sum(
|
||||||
((1 - t)**(n - k)) * (t**k) * choose(n, k) * point
|
((1 - t)**(n - k)) * (t**k) * choose(n, k) * point
|
||||||
for k, point in enumerate(points)
|
for k, point in enumerate(points)
|
||||||
|
|
Loading…
Add table
Reference in a new issue