Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite put_start_and_end_on to work in 3D #1355

Merged
merged 44 commits into from Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
9979407
Use built in numpy functions and better angle_between_vectors
Darylgolden Apr 18, 2021
1fde131
Deleted angle_between since it duplicates the functionality of angle_…
Darylgolden Apr 18, 2021
a842061
Black
Darylgolden Apr 18, 2021
eadc94b
Rewrite put_start_and_end_on to work in 3D
Darylgolden Apr 18, 2021
779daa4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 18, 2021
edd37ea
Merge branch 'master' into psaeo
Darylgolden Apr 18, 2021
f8200ee
Merge branch 'master' into psaeo
Darylgolden Apr 20, 2021
8da8ecd
Merge branch 'master' into psaeo
Darylgolden Apr 20, 2021
74710a6
Fix imports
Darylgolden Apr 20, 2021
55822a0
Fix
Darylgolden Apr 20, 2021
8da1329
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
0969faf
Try to fix tests
Darylgolden Apr 21, 2021
d0fbd07
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
a642a2e
Try to fix tests
Darylgolden Apr 21, 2021
df36974
Update geometry.py
Darylgolden Apr 21, 2021
8df1d6d
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
28f1b87
Try fix
Darylgolden Apr 21, 2021
8c1a563
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
4ee0fb2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
d7eab47
fix attempt
Darylgolden Apr 21, 2021
84e494e
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
62eeb50
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
e212cbf
Try to fix
Darylgolden Apr 21, 2021
8e92e84
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
8bdbd82
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
1480619
Trying to fix AGAIN
Darylgolden Apr 21, 2021
30c5f52
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
0ae0259
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
80726cd
evil hacking fix
Darylgolden Apr 21, 2021
7267cb1
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
f0b27b5
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
817995f
Retrigger checks
Darylgolden Apr 21, 2021
8d2fe11
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
eff65b3
Added test
Darylgolden Apr 21, 2021
7924817
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Apr 21, 2021
f101c7b
Regenerate test data with Dot3D
Darylgolden Apr 21, 2021
94e7a4b
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 21, 2021
c919879
Merge branch 'master' into psaeo
Darylgolden Apr 22, 2021
bc0ea4f
Readd angle_between
Darylgolden Apr 23, 2021
fbadc18
Merge branch 'psaeo' of https://github.com/Darylgolden/manim into psaeo
Darylgolden Apr 23, 2021
0823a62
Fix imports
Darylgolden Apr 23, 2021
74bc89f
Merge branch 'master' into psaeo
Darylgolden Apr 23, 2021
36f5ece
revert back to default vertex type for test
behackl Apr 23, 2021
5d6e0e4
Merge branch 'psaeo' of github.com:Darylgolden/manim into psaeo
behackl Apr 23, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 deletions manim/mobject/geometry.py
Expand Up @@ -1159,8 +1159,9 @@ def scale(self, factor, scale_tips=False, **kwargs):

>>> arrow = Arrow(np.array([-1, -1, 0]), np.array([1, 1, 0]), buff=0)
>>> scaled_arrow = arrow.scale(2)
>>> scaled_arrow.get_start_and_end()
(array([-2., -2., 0.]), array([2., 2., 0.]))
>>> np.round(scaled_arrow.get_start_and_end(), 8) + 0
array([[-2., -2., 0.],
[ 2., 2., 0.]])
>>> arrow.tip.length == scaled_arrow.tip.length
True

Expand Down
10 changes: 9 additions & 1 deletion manim/mobject/mobject.py
Expand Up @@ -33,7 +33,9 @@
from ..utils.paths import straight_path
from ..utils.simple_functions import get_parameters
from ..utils.space_ops import (
angle_between_vectors,
angle_of_vector,
normalize,
rotation_matrix,
rotation_matrix_transpose,
)
Expand Down Expand Up @@ -1527,13 +1529,19 @@ def put_start_and_end_on(self, start, end):
if np.all(curr_vect == 0):
raise Exception("Cannot position endpoints of closed loop")
target_vect = np.array(end) - np.array(start)
axis = (
normalize(np.cross(curr_vect, target_vect))
if np.linalg.norm(np.cross(curr_vect, target_vect)) != 0
else OUT
)
self.scale(
np.linalg.norm(target_vect) / np.linalg.norm(curr_vect),
about_point=curr_start,
)
self.rotate(
angle_of_vector(target_vect) - angle_of_vector(curr_vect),
angle_between_vectors(curr_vect, target_vect),
about_point=curr_start,
axis=axis,
)
self.shift(start - curr_start)
return self
Expand Down
1 change: 0 additions & 1 deletion manim/utils/space_ops.py
Expand Up @@ -11,7 +11,6 @@
"rotation_matrix",
"rotation_about_z",
"z_to_vector",
"angle_between",
"angle_of_vector",
"angle_between_vectors",
"project_along_vector",
Expand Down
Binary file not shown.
16 changes: 16 additions & 0 deletions tests/test_graphical_units/test_threed.py
Expand Up @@ -76,6 +76,22 @@ def construct(self):
self.add(axes)


class MovingVerticesTest(ThreeDScene):
def construct(self):
self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
vertices = [1, 2, 3, 4]
edges = [(1, 2), (2, 3), (3, 4), (1, 3), (1, 4)]
g = Graph(vertices, edges)
Darylgolden marked this conversation as resolved.
Show resolved Hide resolved
self.add(g)
self.play(
g[1].animate.move_to([1, 1, 1]),
g[2].animate.move_to([-1, 1, 2]),
g[3].animate.move_to([1, -1, -1]),
g[4].animate.move_to([-1, -1, 0]),
)
self.wait()


MODULE_NAME = "threed"


Expand Down