Skip to content

add_fixed_orientation_mobjects fails with MathTex #4645

@tobiasBora

Description

@tobiasBora

Description of bug / unexpected behavior

It seems like add_fixed_orientation_mobjects does not work with MathTex (or maybe I'm using it badly?) as the object is rotated.

Expected behavior

The text should not be rotated.

How to reproduce the issue

Code for reproducing the problem
from manim import *

class Tests(ThreeDScene):
    def construct(self):
        sphere = Surface(
            lambda u, v: R * np.array([
                np.sin(v) * np.cos(u),
                np.cos(v),
                np.sin(v) * np.sin(u),
            ]),
            u_range=[0, TAU], v_range=[0, PI],
            resolution=(36, 18),
            fill_color=BLUE_D, fill_opacity=0.0,
            stroke_color=BLUE_E, stroke_width=0.4, stroke_opacity=0.6,
        )
        labels = MathTex(r"|0\rangle")
        self.add_fixed_orientation_mobjects(labels)
        self.play(Create(sphere, lag_ratio=0.01))
        self.play(sphere.animate.set_fill(BLUE_D, opacity=0.30))
        # Move "up" a bit:
        self.move_camera(
            phi=-20 * DEGREES,
            added_anims = [
            ],
            run_time=3.0, rate_func=smooth)
        ## Rotate around Y axis (move_camera is too hard to use if not around z axis)
        self.play(
            Rotate(
                VGroup(m for m in self.mobjects if isinstance(m, (VMobject, Surface))),
                PI/4,
                [0,1,0],
                about_point=ORIGIN,
            ),
            run_time=3.0,
            rate_func=smooth
        )
        self.wait(0.3)

Additional media files

Images/GIFs
Tests.mp4

Logs

Terminal output
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Linux NixOs 25.11
  • RAM:
  • Python version (python/py/python3 --version): 3.13.19
  • Installed modules (provide output from pip list):
PASTE HERE
LaTeX details
  • LaTeX distribution (e.g. TeX Live 2020):
  • Installed LaTeX packages:

Additional comments

EDIT My guess is that there is a clash with the rotation that wants to be applied twice… So far my trick is not to use add_fixed_orientation_mobject, instead I use a dummy point to track the location and always_redraw to place the point at the coordinate of the dummy point with the rotation I want, like this:

class Tests(ThreeDScene):
    def construct(self):
        sphere = Surface(
            lambda u, v: R * np.array([
                np.sin(v) * np.cos(u),
                np.cos(v),
                np.sin(v) * np.sin(u),
            ]),
            u_range=[0, TAU], v_range=[0, PI],
            resolution=(36, 18),
            fill_color=BLUE_D, fill_opacity=0.0,
            stroke_color=BLUE_E, stroke_width=0.4, stroke_opacity=0.6,
        )
        labelp = Circle(0).move_to(label_pos(0, 2))
        labels = always_redraw(lambda: MathTex(r"|0\rangle").move_to(labelp))
        self.add(labels)
        self.add(labelp)
        self.play(Create(sphere, lag_ratio=0.01))
        self.play(sphere.animate.set_fill(BLUE_D, opacity=0.30))
        # Move "up" a bit:
        self.move_camera(
            phi=-20 * DEGREES,
            added_anims = [
            ],
            run_time=3.0, rate_func=smooth)
        ## Rotate around Y axis (move_camera is too hard to use if not around z axis)
        self.play(
            Rotate(
                VGroup(m for m in self.mobjects if isinstance(m, (VMobject, Surface)) and m != labels),
                PI/4,
                [0,1,0],
                about_point=ORIGIN,
            ),
            run_time=3.0,
            rate_func=smooth
        )
        self.wait(0.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions