Manim configuration: an animation engine for mathematical formula visualization

Insert picture description here
Manim is an explanatory mathematics video animation engine. It mainly uses Python to make many mathematical formulas and theorems into visual effects. For the demo video, you can watch the video on the Up main B station (recommended by conscience). Because of sudden whims I want to use it in electromagnetic wave class, so I studied a wave and configured it for the whole afternoon and evening.

First put the address of station B of Stanford boss 3Blue1Brown boss
Insert picture description here

Manim

Because many reference blogs on the Internet are many years ago or many years ago, the official keeps making a lot of changes, so according to their blog, there are many bugs, here I will re-summarize:

Download and install Hombrew and Python3.7

The first thing we need is the package manager Homebrew, which will help us install some packages that pip cannot install correctly. Open the terminal and run the following lines of code to install Homebrew. It is recommended that you do not use a virtual environment during installation. After several attempts, I found that there will be many inexplicable error messages if you install it in the virtual environment at the beginning:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

After installing Homebrew, install Python:

brew install python3

After installing Python, we need to obtain some packages. Return to the terminal and run the following lines of code to get the packages required for installation (cairo, pkg-config, virtualenv)

brew install cairo
brew install pkg-config
Create folder for animation

Create a folder to store the Manim library, I created a folder named Manim in the home directory:
Insert picture description heredownload the source code on Github and put the downloaded code in the folder just created -->/manim3.7

Create and activate a virtual environment

Insert picture description hereRun the following code in turn, if you think the download is slow, you can use Tsinghua's mirror source

(pip install -i https://pypi.tuna.tsinghua.edu.cn/simple 要下的包名)
pip3 install sox
pip3 install ffmpeg
pip3 install latex
pip3 install pycairo
pip3 install -r requirements.txt
Modify the code

Add a folder named "output" in the manim3.7 directory.

Then I changed the code on line 23 of the file constants.py located in the Manim/manim3.7/manimlib folder, and found "Dropbox (3Blue1Brown) / 3Blue1Brown Team Folder"
Insert picture description here

Run test

Open the terminal in the manim3.7 folder, use the virtual environment just created, and run the following code:

python3 -m manim example_scenes.py SquareToCircle -pl

Insert picture description here
Calling the local player to play an animation that converts a rectangle to a circle is a success!

Guess you like

Origin blog.csdn.net/qq_43580646/article/details/104885354