question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Plot a circle in Manim graph using coordinate equations.

See original GitHub issue

Hi,

I want to plot the circle x^2 + y^2 = 25 in Manim. I am currently using the following code to get the corresponding values of y for a given x:

circle = axes.get_graph(
            lambda x: math.sqrt(25 - x**2),
            x_range=[-5,5, 0.01]
        )

However, there will be two values of y for each value of x. This means that I the function only plots a semi-circle. How can I get it to plot the full circle?

Thanks.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

2reactions
NeoPlatocommented, Sep 13, 2020

Exactly!

Then the radius of $\sqrt{25}$ in the implicit equation is merely the radius of the circle all in a single setting.

Also, you don’t have to think about it as much as you would when using the parametric version. Small disadvantage I see here is the circle won’t be an attribute of the axes so you’d either move it independently or add a new method to Axes in manimlib\mobject\coordinate_systems.py to handle this for you, which is recommended.

I think I can sort you out here. Just copy paste this code(better in the CoordinateSystems class than the Axes class since it is the base class thus extending it automatically to ThreeDAxes and NumberPlane and ComplexPlane):

Screenshot 2020-09-13 123337

Add the import line at the top for obvious reasons:

Screenshot 2020-09-13 123548

And you’re good to go!

Quick update on this thing. I just realized that the circle initialized stays at the center meaning if the Axes method was called on a spot that wasn’t the origin the circle would be left there undisturbed which is not helpful. Like so:

        axes = Axes(y_min=0)
        axes.shift(DOWN * 3)
        graph = axes.get_circle(radius=3)
        self.add(axes, graph)
        self.play(
            axes.shift, UP * 4,
            run_time = 3
        )
        self.wait()

Try this on the original version and the circle doesn’t go to the correct origin.

Solution:

Screenshot 2020-09-13 174313

The play method executed in the code above will leave the circle hanging even though it’s been correctly placed this time. For that, remember that Axes is a VGroup so a simple axes.add(circle) will do the trick quite nicely.

Just thought that might help. Happy animating

1reaction
NeoPlatocommented, Sep 13, 2020

Oh that’s easy.

After banging my head against a wall (figuratively of course) my brain reset and I gave up completely on any outside help.

Since then I’ve been studying the original master’s code and actually learning Python and I can say I’m making good progress.

I still would and do watch videos from Theorem of Beethoven cause you grab knowledge where you see it but at this point I’m a big boy with a big man motto

If you can’t do something, find the solution yourself. And if you don’t find the solution even if it’s there, don’t bother, everything in Python is an object, you just craft it yourself

Read more comments on GitHub >

github_iconTop Results From Across the Web

CoordinateSystem - Manim Community v0.17.1
Returns the coordinates of the point on a graph corresponding to an x value. p2c. Abbreviation for point_to_coords(). plot.
Read more >
Example Scenes - manim documentation
Many example scenes are given in example_scenes.py , let's start with the simplest and ... self.play(circle.animate.stretch(4, 0)) self.play(Rotate(circle, ...
Read more >
how can i draw a curve in polar coordinates? r = 2 + 3.cos ...
Depends on what you ask. There are a few things I'm still trying to figure out in Manim so as a community member...
Read more >
3D Graphing | Tutorial 4, Manim Explained - YouTube
Beginning of the Manim Explained series to help people understand how to use Manim (the 3Blue1Brown animation program).
Read more >
The Manim Cast #4 - (3D) Graphing, Camera ... - YouTube
SUbscribe to @vcubingx ! https://www.youtube.com/watch?v=g_5P9AW_segManim Cast Playlist: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found