mirror of
https://github.com/ManimCommunity/manim.git
synced 2026-06-22 10:01:47 +00:00
Fixed Mobject.put_start_and_end_on with same start and end point (#3718)
* fix put_start_and_end_on() at the same point * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
parent
563810a772
commit
0fd16b8918
2 changed files with 10 additions and 2 deletions
|
|
@ -1734,7 +1734,8 @@ class Mobject:
|
|||
curr_start, curr_end = self.get_start_and_end()
|
||||
curr_vect = curr_end - curr_start
|
||||
if np.all(curr_vect == 0):
|
||||
raise Exception("Cannot position endpoints of closed loop")
|
||||
self.points = start
|
||||
return self
|
||||
target_vect = np.array(end) - np.array(start)
|
||||
axis = (
|
||||
normalize(np.cross(curr_vect, target_vect))
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import numpy as np
|
||||
|
||||
from manim import NumberLine
|
||||
from manim import DashedLine, NumberLine
|
||||
from manim.mobject.text.numbers import Integer
|
||||
|
||||
|
||||
|
|
@ -121,3 +121,10 @@ def test_point_to_number():
|
|||
np.testing.assert_array_equal(np.round(num_1, 4), np.round(expected, 4))
|
||||
np.testing.assert_array_equal(np.round(num_2, 4), np.round(expected, 4))
|
||||
np.testing.assert_array_equal(np.round(num_3, 4), np.round(expected, 4))
|
||||
|
||||
|
||||
def test_start_and_end_at_same_point():
|
||||
line = DashedLine(np.zeros(3), np.zeros(3))
|
||||
line.put_start_and_end_on(np.zeros(3), np.array([0, 0, 0]))
|
||||
|
||||
np.testing.assert_array_equal(np.round(np.zeros(3), 4), np.round(line.points, 4))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue