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

V0.18.1 NumberLine's number_to_point() is broken when using add_tip #3740

Open
uwezi opened this issue May 1, 2024 · 1 comment
Open

V0.18.1 NumberLine's number_to_point() is broken when using add_tip #3740

uwezi opened this issue May 1, 2024 · 1 comment

Comments

@uwezi
Copy link
Contributor

uwezi commented May 1, 2024

Description of bug / unexpected behavior

the method .number_to_point() does not provide the correct position in scene coordinates

Expected behavior

...well, it should provide the correct location along the numberline

How to reproduce the issue

Code for reproducing the problem
class group2(Scene):
    def construct(self):
        axes = NumberLine(x_range=[-5,5.2,1]).add_numbers().add_tip(tip_length=0.5,tip_width=0.1)
        t = [MathTex("h_{i}") for i in range(1,11)]
        self.add(axes)
        for i in range(1,10):
            self.add(t[i].next_to(axes.n2p(i-6),DOWN,buff=0.5))
            self.add(Dot().move_to(axes.n2p(i-6)))

Without the added tip, the positions are correct

class group2(Scene):
    def construct(self):
        axes = NumberLine(
            x_range=[-5,5.2,1]).add_numbers()
        t = [MathTex("h_{i}") for i in range(1,11)]
        self.add(axes)
        for i in range(1,10):
            self.add(t[i].next_to(axes.n2p(i-6),DOWN,buff=0.5))
            self.add(Dot().move_to(axes.n2p(i-6)))

Also adding the tip from the start works

class group2(Scene):
    def construct(self):
        axes = NumberLine(
            x_range=[-5,5.5,1],
            include_tip=True,
        ).add_numbers()
        t = [MathTex("h_{i}") for i in range(1,11)]
        self.add(axes)
        for i in range(1,10):
            self.add(t[i].next_to(axes.n2p(i-6),DOWN,buff=0.5))
            self.add(Dot().move_to(axes.n2p(i-6)))

Additional media files

Images/GIFs

image

image

image

System specifications

System Details
  • OS (with version, e.g., Windows 10 v2004 or macOS 10.15 (Catalina)): Windows 10 64 bit
  • Python version (python/py/python3 --version): 3.11.6

Additional comments

@uwezi uwezi changed the title V0.18.1 NumberLine's number_to_point() is broken wehn using add_tip V0.18.1 NumberLine's number_to_point() is broken when using add_tip May 1, 2024
@uwezi
Copy link
Contributor Author

uwezi commented May 1, 2024

The problem only arises when later adding a tip to the NumberLine() object. Scaling of both tipped and untipped nmberlines works as expected

class nlineScaling(Scene):
    def construct(self):
        nline1 = NumberLine(
            x_range=[0,10,1],
            length=8,
            font_size=16,
            label_direction=UP,
        ).add_numbers().to_corner(UL)
        dot1 = Dot(nline1.n2p(5),color=RED)
        self.add(nline1, dot1)

        nline2 = nline1.copy().scale(1.5).next_to(nline1,DOWN,aligned_edge=LEFT)
        dot2 = Dot(nline2.n2p(5),color=BLUE)
        self.add(nline2,dot2)

        nline3 = nline2.copy().next_to(nline2,DOWN,aligned_edge=LEFT)
        nline3.add_tip()
        dot3 = Dot(nline3.n2p(5),color=YELLOW)
        self.add(nline3,dot3)

        nline4 = NumberLine(
            x_range=[0,10,1],
            length=12,
            font_size=16,
            label_direction=UP,
            include_tip=True,
        ).add_numbers().next_to(nline3,DOWN,aligned_edge=LEFT)
        dot4 = Dot(nline4.n2p(5),color=TEAL)
        self.add(nline4,dot4)

        nline5 = NumberLine(
            x_range=[0,10.5,1],
            length=12.5,
            font_size=16,
            label_direction=UP,
            include_tip=True,
        ).add_numbers().next_to(nline4,DOWN,aligned_edge=LEFT)
        dot5 = Dot(nline5.n2p(5),color=ORANGE)
        self.add(nline5,dot5)

        nline6 = nline5.copy().scale(0.7).next_to(nline5,DOWN,aligned_edge=LEFT)
        dot6 = Dot(nline6.n2p(5),color=GREEN)
        self.add(nline6,dot6)

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant