3b1b / manim

Animation engine for explanatory math videos
MIT License
60.44k stars 5.71k forks source link

Is there any way to animate Spheres or other curved 3D objects? #143

Closed ddxtanx closed 5 years ago

ddxtanx commented 6 years ago

I've tried to use the Sphere() class in topics/three_dimensions.py but, by default, it is very 'point'-y and not shaded. How could I generate something similar to the spheres and curved 3D objects in 3B1B videos?

domino566 commented 6 years ago

There's an old_projects/three_dimensions.py file with a class Sphere and a function generate_points, could this be what you're looking for?

class Sphere(Mobject2D):
    def generate_points(self):
        self.add_points([
            (
                np.sin(phi) * np.cos(theta),
                np.sin(phi) * np.sin(theta),
                np.cos(phi)
            )
            for phi in np.arange(self.epsilon, np.pi, self.epsilon)
            for theta in np.arange(0, 2 * np.pi, 2 * self.epsilon / np.sin(phi)) 
        ])
        self.set_color(BLUE)

    def unit_normal(self, coords):
        return np.array(coords) / np.linalg.norm(coords)
3b1b commented 6 years ago

At the moment, there is not. I have been using Grapher to generate most curved 3d visuals. Pull requests accepted though :)

eulertour commented 5 years ago

Closing, as this was addressed in #145.