diff options
author | Leonard Kugis <leonard@kug.is> | 2020-08-22 02:43:45 +0200 |
---|---|---|
committer | Leonard Kugis <leonard@kug.is> | 2020-08-22 02:43:45 +0200 |
commit | 3b47fad88c8b714c83c1c90cf6726d85688b300f (patch) | |
tree | dd3a110bd9fd159ec34ceb643eb16e6d71e8ca2b /AutopyExtended | |
parent | a4a32e491de5ad56f3d01ed713202ae378e2672a (diff) |
BezierCurve
Added linear interpolation between two points.
Now non-discrete times are valid.
Diffstat (limited to 'AutopyExtended')
-rw-r--r-- | AutopyExtended/Curve/CurveBezier.py | 8 | ||||
-rw-r--r-- | AutopyExtended/mouse.py | 3 |
2 files changed, 7 insertions, 4 deletions
diff --git a/AutopyExtended/Curve/CurveBezier.py b/AutopyExtended/Curve/CurveBezier.py index 421b93d..4aedb9d 100644 --- a/AutopyExtended/Curve/CurveBezier.py +++ b/AutopyExtended/Curve/CurveBezier.py @@ -10,15 +10,17 @@ class CurveBezier(Curve): 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.dot(x, poly) - self.__y = np.dot(y, poly) + 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 (self.__x[t], self.__y[t]) + 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): diff --git a/AutopyExtended/mouse.py b/AutopyExtended/mouse.py index e50c7ec..0b06c11 100644 --- a/AutopyExtended/mouse.py +++ b/AutopyExtended/mouse.py @@ -1,3 +1,4 @@ import autopy -def move(target, time, curve, ) +def move(target, time, curve, time_scale=(lambda x : 1 * x)): + |