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

Chemistry figures in manim #10

Open
Luis-Henrique655 opened this issue Sep 11, 2019 · 5 comments
Open

Chemistry figures in manim #10

Luis-Henrique655 opened this issue Sep 11, 2019 · 5 comments

Comments

@Luis-Henrique655
Copy link

I was trying to make molecules ,with manim, arraying polygons, lines and letters and it turn out to be a huge pain. Does someone know if it's possible to install a LaTex package (Chemfig) and use LaTex (the same way we use to generate equations) but to generate LaTex figures in manim ?

@TravorLZH
Copy link
Contributor

TravorLZH commented Sep 11, 2019 via email

@TravorLZH
Copy link
Contributor

TravorLZH commented Sep 11, 2019

The problem with this is that the bonding between atoms cannot be shown properly:

problem

@TravorLZH
Copy link
Contributor

TravorLZH commented Sep 11, 2019 via email

@Luis-Henrique655
Copy link
Author

Luis-Henrique655 commented Sep 12, 2019 via email

@Elteoremadebeethoven
Copy link

That is because the TextMobject class has a thickness of zero, and those symbols have no thickness, if you use the Write animation you can see they are drawn but disappear, to solve that you can do two things.
If you want to use the chemfig package you will have to identify each symbol of the formula and give them a thickness:

class Chem(Scene):
    def construct(self):
        f1 = TextMobject(r"\chemfig{O=H}")
        elements = self.show_index(f1[0])
        self.add(elements)
        f1[0][2:4].set_stroke(None,1,1)
        self.play(Write(f1))
        self.wait()

    def show_index(self,mob,width=0.07):
        n = VGroup()
        for element,index in zip(mob,range(len(mob))):
            i = Text(f"{index}",color=RED).set_width(width)
            i.next_to(element,UP,buff=0)
            n.add(i)
        return n

Chem

Or, you can look for another chemical package whose symbols are shown by default, you can try this:
https://tex.stackexchange.com/questions/52722/can-you-make-chemical-structure-diagrams-in-latex

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

No branches or pull requests

3 participants