mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Revert away from using curve_to_quadratic
This commit is contained in:
parent
8b3aa8f5c6
commit
e20efda3df
1 changed files with 9 additions and 13 deletions
|
@ -1,7 +1,6 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from fontTools.cu2qu.cu2qu import curve_to_quadratic
|
|
||||||
|
|
||||||
import moderngl
|
import moderngl
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
@ -447,22 +446,19 @@ class VMobject(Mobject):
|
||||||
self.throw_error_if_no_points()
|
self.throw_error_if_no_points()
|
||||||
last = self.get_last_point()
|
last = self.get_last_point()
|
||||||
# Note, this assumes all points are on the xy-plane
|
# Note, this assumes all points are on the xy-plane
|
||||||
approx_2d = curve_to_quadratic(
|
v1 = handle1 - last
|
||||||
[last[:2], handle1[:2], handle2[:2], anchor[:2]],
|
v2 = anchor - handle2
|
||||||
0.1 * get_norm(anchor - last)
|
angle = angle_between_vectors(v1, v2)
|
||||||
)
|
if self.use_simple_quadratic_approx and angle < 45 * DEGREES:
|
||||||
if approx_2d is not None and len(approx_2d) % 2 == 1:
|
quad_approx = [last, find_intersection(last, v1, anchor, -v2), anchor]
|
||||||
approx_3d = np.zeros((len(approx_2d), 3))
|
|
||||||
approx_3d[:, :2] = approx_2d
|
|
||||||
else:
|
else:
|
||||||
approx_3d = get_quadratic_approximation_of_cubic(
|
quad_approx = get_quadratic_approximation_of_cubic(
|
||||||
last, handle1, handle2, anchor
|
last, handle1, handle2, anchor
|
||||||
)
|
)
|
||||||
|
if self.consider_points_equal(quad_approx[1], last):
|
||||||
if self.consider_points_equal(approx_3d[1], last):
|
|
||||||
# This is to prevent subpaths from accidentally being marked closed
|
# This is to prevent subpaths from accidentally being marked closed
|
||||||
approx_3d[1] = midpoint(*approx_3d[1:3])
|
quad_approx[1] = midpoint(*quad_approx[1:3])
|
||||||
self.append_points(approx_3d[1:])
|
self.append_points(quad_approx[1:])
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def add_quadratic_bezier_curve_to(self, handle: Vect3, anchor: Vect3):
|
def add_quadratic_bezier_curve_to(self, handle: Vect3, anchor: Vect3):
|
||||||
|
|
Loading…
Add table
Reference in a new issue