diff options
author | Leonard Kugis <leonard@kug.is> | 2020-08-22 16:02:17 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2020-08-22 16:02:17 +0200 |
commit | f43f909bf20dafb2c10520815282046cffe495f2 (patch) | |
tree | 5be52b3a048c0b2755a670de4269460353bc9760 /AutopyExtended/Curve/CurveBezier.py | |
parent | 3b47fad88c8b714c83c1c90cf6726d85688b300f (diff) |
Refactoring, Bezier
Refactored module layout.
Added missing dependencies to setup.
Added time scaling to curves.
Diffstat (limited to 'AutopyExtended/Curve/CurveBezier.py')
-rw-r--r-- | AutopyExtended/Curve/CurveBezier.py | 27 |
1 files changed, 0 insertions, 27 deletions
diff --git a/AutopyExtended/Curve/CurveBezier.py b/AutopyExtended/Curve/CurveBezier.py deleted file mode 100644 index 4aedb9d..0000000 --- a/AutopyExtended/Curve/CurveBezier.py +++ /dev/null @@ -1,27 +0,0 @@ -import numpy as np - -from Curve import Curve -from scipy.special import comb - -class CurveBezier(Curve): - def __init__(self, cp, tn): - self.__tn = tn - x = np.array([p[0] for p in cp]) - y = np.array([p[1] for p in cp]) - t = np.linspace(0, 1, tn) - poly = np.array([CurveBezier.bernstein(i, len(cp) - 1, t) for i in range(0, len(cp))]) - self.__x = np.flip(np.dot(x, poly)) - self.__y = np.flip(np.dot(y, poly)) - - def point(self, t, t_target=None): - if(t_target == None): - t_target = self.__tn - if(t_target != self.__tn): - raise ValueError("t_target must be equal to tn.") - return np.add((self.__x[int(np.floor(t))], self.__y[int(np.floor(t))]), - np.subtract((self.__x[int(np.ceil(t))], self.__y[int(np.ceil(t))]), - (self.__x[int(np.floor(t))], self.__y[int(np.floor(t))])) * (t - np.floor(t))) - - @staticmethod - def bernstein(i, n, t): - return comb(n, i) * (t ** (n - i)) * (1 - t) ** i |