Hacker News new | past | comments | ask | show | jobs | submit login
Manim – an animation engine for explanatory math videos (3b1b.github.io)
905 points by vermilingua on March 18, 2021 | hide | past | favorite | 75 comments



There is also the Manim Community Edition: https://github.com/ManimCommunity/manim/

According to the original Manim's readme, it's recommended to use the Community Edition, since it's updated more often.


If curious, past threads:

Show HN: I made a parser visualizer using manim - https://news.ycombinator.com/item?id=26382729 - March 2021 (15 comments)

A Manim Code Template - https://news.ycombinator.com/item?id=24985609 - Nov 2020 (1 comment)

Manim: Animation engine for explanatory math videos - https://news.ycombinator.com/item?id=24926947 - Oct 2020 (19 comments)

Manim – 3Blue1Brown's animation engine for explanatory math videos - https://news.ycombinator.com/item?id=19716019 - April 2019 (80 comments)

This one is a dupe because Oct 2020 was less than a year ago (https://news.ycombinator.com/newsfaq.html) but I think we can leave it up.


Grant helped out with this MIT course last fall:

https://computationalthinking.mit.edu/Fall20/lecture26/

I believe he was going to do some of the visualizations


This video linked from the course is excellent, https://www.youtube.com/watch?v=g8RkArhtCc4


This video is bananas awesome. I'd start writing Julia right now if it wasn't for the 1-indexing.


Julia also supports arbitrary indexing [-1], you can even start from a negative number!

[-1] https://docs.julialang.org/en/v1/devdocs/offset-arrays/


Don't you have issues with library calls that want 1-based arrays?


No. Multiple dispatch means that libraries should just be able to handle it. If you ever run into problems, file a bug report. It should get fixed pretty quickly.


Honest question, is it that hard to just adjust to 1-indexing? I switch languages all the time and they all have their different quirks and I find it really hard to understand why people cannot deal with for example 1-indexing. From the outside looking in it seems like one of the easier things to adjust to?



It's intuitive to me that the option "c) 2 ≤ i ≤ 12" is the only acceptable answer, since it is the only range you can tell immediately at a glance what numbers are included: 2, ..., 12. There shouldn't be a 1 or a 13 in the notation if there won't be a 1 or a 13 in the sequence it's describing -- it's just bad design.

If you select the option "c) 2 ≤ i ≤ 12", then Dijkstra's subsequent argument for zero-indexing becomes an argument for one-indexing, because a sequence of length N yields the range 1 <= i <= N when subscripting with 1, but 0 <= i <= N-1 when starting at 0. The latter is uglier than the former.


It's my gut feeling that your preference yields an equivalent amount of ugly N+1.


My personal experience using Lua/love2d for some (amateur/hobbyist) game programming is that the adjustment really wasn't too difficult at all -- I've run into an off-by-one error or two, but not at any greater (or reduced) frequency compared to 0-indexed languages AFAICT. Obviously, some of the sibling comments here disagree, so the only reasonable conclusion I can draw is that it varies from person to person how much they care and how much effort it takes to adjust.

At the end of the day, like all language design decisions involving an arbitrary choice among reasonable options, you get used to it once you use the language enough (and also some folks will refuse to ever use the language because of it for aesthetic reasons).


Yes.

I've used many languages, and I don't have much problem with any quirks or major differences (Haskell, JavaScript, ...). The only language I've bounced off of is Prolog, and I'm planning another attempt.

But I've done a lot of low level programming, and 0-based arrays are a no-brainer to deal with. Switching to 1-based arrays throws out all of my intuitions and makes me have to recalculate everything, which is error-prone.


Unless you use proper index types (Offset and Ordinal) instead of naked ints, all indexing is error-prone.


Yes. It looks wrong and feels wrong. I can adjust to indentation styles, programming styles, etc. but 1-based indexing is an absolute deal-breaker for me. It's one of the few things the programming community has settled on - indexing starts at 0, as it is mathematically the most natural start.


> It's one of the few things the programming community has settled on - indexing starts at 0, as it is mathematically the most natural start.

When you're in the supermarket and you're counting how many items are in your shopping cart, do you start from 0?


It depends on what you think you're doing.

If you are counting, 1-based makes a lot of sense. If you're indexing, they're equally valid approaches. However, if you're indexing then you should be able to use an arbitrary range and not be restricted to one or the other (with a mapping function from your actual range to the language's base).


> When you're in the supermarket and you're counting how many items are in your shopping cart, do you start from 0

Yes, because the cart starts empty. But, more to the point, I don't call the thing I put into the cart that causes it not to be empty the zeroth item.


You start with an empty cart, right?


The scientific programming community, starting with Fortran, has, on the contrary, settled on 1, because it is mathematically the most natural start.


And yet, the set of natural numbers in mathematics is most often taken to start at 1. Mathematicians don’t have a problem with indexing.


In Sweden, the set usually referred to as "de naturliga talen" (the natural numbers) is any number n such that 0 <= n.

Or, at least, that was the case when I did maths there. No idea what the default interpretation is these days.

This is mostly why I don't say "natural numbers" and instead say "positive integers" or "non-negative integers", depending on if I want 0 included or not.


Is it? Most nat's are built from zero and succ(n) in my experience.


(I'm a mathematician)

Honestly, not that many people in math think about the construction of the natural numbers frequently. Yeah, we learn about it of course, but that's about it. Very often the natural numbers do not include 0. Often they do. I've seen $\mathbb Z_{\geq0}$ and $\mathbb Z_+$ used to avoid having to worry about it.

Hell, different countries can't even agree on whether 0 is positive. In France, 0 is considered both positive and negative. In USA, 0 is considered neither.

(quick edit: I realize my last paragraph makes the $\mathbb Z_+$ option seem weird. I do math in the States.)


That's what Wolfram Mathworld suggests: specifying a subset of the integers. :-)


Only if you need zero, which you don't need for indexing. Peano's original axioms started from 1 (which is logically equivalent to starting from 0, or -1, or potato) if all you are doing is counting)


Database auto-indexed columns have entered the chat.


It is a pain, yes, after decades of 0-indexed languages! I switched to mostly-Julia from mostly-C in the last year, and the 1-indexing is the main irritating thing. I have to learn different ways of doing things, which I guess I haven't yet, so the parts in my programs dealing with 1-indexing seem cumbersome and fiddly, every time. 0-indexing just seems mathematically much simpler. And I like things making things as simple as possible. Maybe as I learn different habits, that impression will go away.

It's also about the only thing I really don't like about Julia – so I can understand someone saying 1-indexing is a deal-breaker.


> Maybe as I learn different habits, that impression will go away.

I'd bet this is true. It doesn't seem fiddly to me as a mathematician. Thinking habits can be really hard to get past though, so I also understand people not liking 1-based. I just think the argument from math is wrong.


Tough luck. Using 0-indexing would have lost Matlab users to the Julia community. So they consciously decided to rather lose you. :-)

I got used to switching between 0/1-indexing. The only place it actually hurts is when using modulo to remain within some range. And this is needed much much less in Julia than in C and C-like.


Can't you just use mod(x, 1:n)? Or mod(i, eachindex(vals))?


Lol, this is so nice. It is literally what OP asked for: " modulo to remain within some range" is just mod(myvalue, myrange)


It's funny, from the votes on my comment it seems like I came across as seriously criticizing Julia (a language I admire) rather than just being hyped about that video (which is excellent).


I'll accept using modulo as an argument when CPU manufacturers finally do the sane thing and make sure that x mod n is always a non-negative integer.


Julia has the function mod1 which is just mod + 1, just in case that's ever useful for you :)


Come over to VBA! We do both! Option base 1/0


The course is kind of all over the place. There isn't a lot of focus in the content and the quality of the teaching is inconsistent. Grant's videos were the best by far.


Manim is the inspiration for a similar package in Julia, Javis.jl [0].

0: https://github.com/Wikunia/Javis.jl


As well as the Haskell reanimate package: https://github.com/reanimate/reanimate


Anyone know of any JavaScript editions?


Grant has been one of the inspirations since my early BE days (that was years ago). I got so much inspired from manim that I tried to make my own animation tool, panim [0] where I implemented mathematical concepts I understood. Nowadays, whenever I am in a rut, I jump back to panim and try to jot down my ideas into code.

(Say, "panim" name might be a gimmick?)

--- [0] - https://github.com/NISH1001/panim


I always wondered how 3B1B makes the animations in his videos. Super pleased to see it's available as a Python library. Can't wait to play around with this!


As a teacher, I'd like to use this in presentation slides, i.e. pause the output at specific times and continue only after a button is pressed. Does anyone know if there exists a tool, e.g., to automatically pause MP4 playback at specific times?


I built exactly this in my Manim-based library, code-video-generator [1] (via the code-video-generator command and the --slides flag). It basically turns any Manim scene.wait() call into a pause that I can then advance with a clicker. I used it for this video [2], where I was recording in front of a green screen, but wanted the exact control when the animation continued. code-video-generator played the video fullscreen, which I then captured via obs [3] and used the obs display as a monitor to see if I was pointing at the right spot. Was a bit tricky to get all set up but worked pretty well.

[1] https://github.com/sleuth-io/code-video-generator [2] https://youtu.be/e21hJnB9J5k?t=44 [3] https://obsproject.com/


Don't know how user friendly you'd like this to be, but VLC has a text-based remote control interface: https://wiki.videolan.org/documentation:modules/rc/

This allows you to e.g. get the current time (get_time) and pause playback (pause). So you just have to write a small script that issues the commands the way you want and you'll be good.


if you are comfortable with LaTeX, you can use the animate package on beamer slides. It does just that, and allows both playing the animation or running it frame by frame (fwd and back).


manim works by generating a "partial movie file" for each animation, i.e. a single mp4 file for each scene.wait() call and so on. The final output just stitches these together.

I did exactly what you want using a small reveal.js plugin that parses the list of partial files generated by manim and inserts the corresponding video files into the presentation in thst order, it worked quite well. Let me know if you're interested and I'll throw it up on a GitHub gist.


If you want to stop at specified times, you could just split the video across several slides.

Or you could pause the video manually; in Keynote, press K to play/pause.


I remember playing with Manim last year. I wrote a blog-post regarding the same: https://pncnmnp.github.io/blogs/manim.html

Some of their older documentation (now less relevant) is available on Internet Archive: https://web.archive.org/web/20200122124703/https://manim-tb-...


The single most awesome visualization I've seen to date that uses Manim and Grant has made some amazing stuff. This video removes all mystery of how ReLU activation works. [0]

[0]https://www.youtube.com/watch?v=gmjzbpSVY1A


That this is not called Manin is a lost opportunity. https://en.wikipedia.org/wiki/Yuri_Manin



מנום or מנים ?

In any case, if they were fighting mathematicians, it would be pretty awesome.


There's also MathBox, which seems to take a more D3-style approach to creating diagrams: https://github.com/unconed/mathbox

Examples in a presentation: http://acko.net/files/gltalks/pixelfactory/online.html#35

Some documentation: https://github.com/unconed/mathbox/blob/master/docs/intro.md


It reminds me of the quote from SICP whenever i a domain specific languages frameworks etc

"Establishing new languages is a powerful strategy for control-ling complexity in engineering design; we can often enhance ourability to deal with a complex problem by adopting a new lan-guage that enables us to describe (and hence to think about)the problem in a different way, using primitives, means of com-bination, and means of abstraction that are particularly wellsuited to the problem at hand." -- Harold Abelson


I guess this was used by Sentdex [0] in the Neural Networks from Scratch series.

[0] https://youtu.be/gmjzbpSVY1A?t=52


Looks to me more like they used a compositor like AE or Blackmagic Fusion/Resolve.


Always wondered how 3blue1brown did his animations. I always find them hypnotic and entertaining, even though the math is going way over my head.


For anyone looking for a Docker container, it's here: https://hub.docker.com/r/manimcommunity/manim.


This is amazing. I'm looking for a low-code / no-code version of something like this for my video essays. Right now I have to rely on Adobe After effects which is a) costly and b) a little too much kitchen sink.

Suggestions welcome.


Since the day I watched the Interstellar movie, I always thought of understanding and making the black hole simulation. I guess I could make it now.


The user "rantonels" (IIRC) on /r/physics has some posts about general relativity based ray tracing of black holes



Is this a previewer for manim? Really reminds me of https://bl.ocks.org/, https://observablehq.com/, https://asciinema.org/, and https://nbviewer.jupyter.org/.

Really enjoy these kinds of tools. Though I wish you didn't need an account to preview or upload content to manim.



I always wondered how 3blue1brown made his animation clips. They are very good.


I always wondered how 3blue1brown created his videos! Thanks for sharing


This feels like something that should exist on javascript/typescript, and produce results directly on a Canvas. Having to use an intermediate video feels jarring on a website. I guess people producing videos directly (Youtubers) will find it more useful.


I don't see much use in that for non-interactive content. Rendering something like that isn't cheap (computationally) and doing it potentially millions of times for a popular piece of content is just wasteful. A canvas element also wouldn't be any less "jarring", since ultimately, it's still just a box of pixels.

As for interactive content, you'd probably be better off using something else that was created with a focus on realtime performance and portability. You


This is amazing. I can totally see using this to make presentations.


Can it do 3d animations?



Nice update


[flagged]


I'm here can counterspam this with tools they have on-hand. Please?




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: