manim icon indicating copy to clipboard operation
manim copied to clipboard

Artifacts on vertices when rotating

Open NunezuJo opened this issue 8 months ago • 4 comments

Description of bug / unexpected behavior

There are weird artifacts on vertices when rotating a Polyhedron

Expected behavior

clean vertices or edge tips

How to reproduce the issue

This is an example

example
class PolyhedronSubMobjects(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
        octahedron = Octahedron(edge_length = 3)
        octahedron.graph[0].set_color(RED)
        octahedron.faces[2].set_color(YELLOW)
        self.add(octahedron)
        self.play(Rotate(octahedron, angle=2*PI, axis=[0,1,0], about_point=octahedron.get_center(), rate_func=linear, run_time=4))

NunezuJo avatar Mar 29 '25 15:03 NunezuJo

I can reproduce what I think is the issue with the following code:

from manim import *

class PolyhedronSubMobjects(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
        octahedron = Octahedron(edge_length = 4)
        octahedron.graph[0].set_color(RED)
        octahedron.faces[2].set_color(YELLOW)
        self.add(octahedron)
        octahedron.rotate(angle = 9*2*PI / 240, 
                          axis = [0, 1, 0], 
                          about_point=octahedron.get_center())

Which renders as follows.

Image

I have cropped the image to focus on what I think is the issue. At one of the corners, the lines have thin spikes that extend beyond the corner. The spikes appear in one frame and is gone in the next.

Image

henrikmidtiby avatar Apr 28 '25 18:04 henrikmidtiby

Same question!!!

from manim import *

class SuperCube4(ThreeDScene):
    def construct(self):
        obj = Icosahedron(graph_config={"vertex_type": lambda : Dot3D(radius=0.05)})
        self.add(obj)

Image

changzeng avatar May 30 '25 15:05 changzeng

It seems to me that the issue is related to drawing the edges of the faces of the polyhedra. If the face edges are not drawn / visible the issue disappears.

In the example below, the verticies have been made invisible (by setting the radius of the Dot3D to a very small value) and the stroke_opacity of the faces is set to zero.

from manim import *

class PolyhedronSubMobjects(ThreeDScene):
    def construct(self):
        self.set_camera_orientation(phi=75 * DEGREES, theta=30 * DEGREES)
        octahedron = Octahedron(edge_length = 4, 
                                faces_config = {
                                    "fill_color": WHITE,
                                    "stroke_opacity": 0.0, # Remove artifacts from the vertices
                                    },
                                graph_config = {
                                    "vertex_type": Dot3D,
                                    "vertex_config": {
                                        "radius": 0.001, # Effectively hide the vertex markers
                                    },
                                    "edge_config": {
                                        "stroke_color": WHITE,
                                        "stroke_width": 2,  # Needed to avoid artifacts near verticies
                                        "stroke_opacity": 1.0,
                                    }
                                })
        octahedron.graph[0].set_color(RED)
        octahedron.faces[2].set_color(YELLOW)
        self.add(octahedron)

Image

henrikmidtiby avatar Jun 02 '25 06:06 henrikmidtiby

It worked for me perfectly!!! Now they are rendered nicely!!

Thank you very much!! You are incredible!!

NunezuJo avatar Jun 25 '25 18:06 NunezuJo