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

TransformMatchingTex doesn't works well with sqrt square root operator #1525

Closed
Sylk1-9 opened this issue May 16, 2021 · 1 comment · Fixed by #1527
Closed

TransformMatchingTex doesn't works well with sqrt square root operator #1525

Sylk1-9 opened this issue May 16, 2021 · 1 comment · Fixed by #1527
Labels
issue:bug Something isn't working... For use in issues

Comments

@Sylk1-9
Copy link

Sylk1-9 commented May 16, 2021

Description of bug / unexpected behavior

TransformMatchingTex does not work as expected when transforming from one MathTex object to an other which contains a Latex sqrt operator

  • The last character in the square-root of the last MathTex object is invisible (in the following example, the parenthesis )
  • The transform_mismatches is therefore badly rendered

Expected behavior

  • In the following example, the exponent 2 should transform into the square root.
  • The last character under the square root (the closing parenthesis ) should be visible.

How to reproduce the issue

``

Code for reproducing the problem. Adapted and simplfied version from 3B1B manim's TExTransformExample in his repository, https://3b1b.github.io/manim/getting_started/example_scenes.html
class TexTransformExampleSimple(Scene):
    def construct(self):
        to_isolate = ["A", "B", "C", "=", "(", ")"]
        lines = VGroup(
            MathTex("A^2 = (C + B)(C - B)", substrings_to_isolate=to_isolate),
            MathTex("A = \\sqrt{(C + B)(C - B)}", substrings_to_isolate=to_isolate)
        )
        lines.arrange(DOWN, buff=LARGE_BUFF)
        self.add(lines[0])
        self.play(TransformMatchingTex(lines[0], lines[1], transform_mismatches=True), run_time=2)
        self.wait()

Additional media files

Images/GIFs

TexTransformExampleSimple_ManimCE_v0 6 0

Logs

Terminal output
Manim Community v0.6.0

[05/16/21 23:42:15] 
                    DEBUG    Animation received extra kwargs: {'final_alpha_value': 0}                                                     animation.py:50
                    DEBUG    Animation received extra kwargs: {'final_alpha_value': 0}                                                     animation.py:50
                    DEBUG    Animation received extra kwargs: {'final_alpha_value': 0}                                                     animation.py:50
                    DEBUG    Hashing ...                                                                                                    hashing.py:240
                    DEBUG    Hashing done in 0.333753 s.                                                                                    hashing.py:253
                    DEBUG    Hash generated :  450974505_3223459120_2098723146                                                              hashing.py:257
                    DEBUG    List of the first few animation hashes of the scene: ['450974505_3223459120_2098723146']                cairo_renderer.py:108
[05/16/21 23:42:21] INFO     Animation 0 : Partial movie file written in {'/path/to/project/mani scene_file_writer.py:401
                             m/media/videos/scene/1080p60/partial_movie_files/TexTransformExampleSimple/450974505_3223459120_2098
                             723146.mp4'}
                    DEBUG    Animation with empty mobject                                                                                  animation.py:62
                    DEBUG    Hashing ...                                                                                                    hashing.py:240
                    DEBUG    Hashing done in 0.196513 s.                                                                                    hashing.py:253
                    DEBUG    Hash generated :  2788726626_1615497636_227427286                                                              hashing.py:257
                    INFO     Animation 1 : Using cached data (hash : 2788726626_1615497636_227427286)                                cairo_renderer.py:100
                    DEBUG    List of the first few animation hashes of the scene: ['450974505_3223459120_2098723146',                cairo_renderer.py:108
                             '2788726626_1615497636_227427286']
                    DEBUG    Partial movie files to combine (2 files): ['/path/to/project/manim/ scene_file_writer.py:450
                             media/videos/scene/1080p60/partial_movie_files/TexTransformExampleSimple/450974505_3223459120_209872
                             3146.mp4', '/path/to/project/manim/media/videos/scene/1080p60/parti
                             al_movie_files/TexTransformExampleSimple/2788726626_1615497636_227427286.mp4']
[05/16/21 23:42:25] INFO                                                                                                          scene_file_writer.py:585
                             File ready at /path/to/project/manim/media/videos/scene/1080p60/Tex
                             TransformExampleSimple_ManimCE_v0.6.0.gif

                    INFO     Rendered TexTransformExampleSimple                                                                               scene.py:217
                             Played 2 animations

System specifications

System Details
  • MacOS 10.14.6 Mojave (patcher), macbook pro 2011
  • RAM: 16 Go
  • Python 3.9.5
  • Installed modules (provide output from pip list):
appnope                0.1.2
backcall               0.2.0
certifi                2020.12.5
chardet                4.0.0
click                  7.1.2
click-default-group    1.2.2
cloup                  0.7.1
colorama               0.4.4
colour                 0.1.5
commonmark             0.9.1
cycler                 0.10.0
Cython                 0.29.22
decorator              4.4.2
glcontext              2.3.3
idna                   2.10
ipython                7.22.0
ipython-genutils       0.2.0
jedi                   0.18.0
kiwisolver             1.3.1
manim                  0.6.0
manimgl                1.0.1.dev18 /Users/sylvann/GitCloned/manim/manim
ManimPango             0.2.4
mapbox-earcut          0.12.10
matplotlib             3.4.0
mccabe                 0.6.1
moderngl               5.6.4
moderngl-window        2.3.0
mpmath                 1.2.1
multipledispatch       0.6.0
networkx               2.5.1
numpy                  1.20.2
parso                  0.8.2
pexpect                4.8.0
pickleshare            0.7.5
Pillow                 8.1.2
pip                    21.1.1
prompt-toolkit         3.0.18
ptyprocess             0.7.0
pybind11               2.6.2
pycairo                1.20.0
pycodestyle            2.7.0
pydub                  0.25.1
pyflakes               2.3.1
pyglet                 1.5.15
Pygments               2.8.1
PyGObject              3.40.1
pyobjc-core            7.1
pyobjc-framework-Cocoa 7.1
PyOpenGL               3.1.5
pyparsing              2.4.7
pyrr                   0.10.3
python-dateutil        2.8.1
PyYAML                 5.4.1
requests               2.25.1
rich                   6.2.0
scipy                  1.6.3
screeninfo             0.6.7
setuptools             56.0.0
six                    1.15.0
sympy                  1.7.1
tqdm                   4.59.0
traitlets              5.0.5
typing-extensions      3.10.0.0
urllib3                1.26.4
validators             0.18.2
watchdog               2.1.0
wcwidth                0.2.5
wheel                  0.36.2
LaTeX details
  • LaTeX distribution : MacTeX 2021
FFMPEG

Output of ffmpeg -version:

4.4

Additional comments

A work around for the disapearing of the last character under the sqrt is to add an other random character to its right. But it is clearly not viable, and doesn't solve the morphing issue.

@behackl
Copy link
Member

behackl commented May 16, 2021

Thanks for your report! Turns out the issue is that \sqrt is not always handled correctly (in particular in the case where the TeX string is split at the first symbol under the square root (you can check that \sqrt{x(C + B)(C - B)} renders correctly.

I've proposed a fix in #1527.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue:bug Something isn't working... For use in issues
Projects
None yet
2 participants