ManimCommunity / ManimCommunity/manim

Issue when taking Difference of an Intersection but only for some clips

Open
#3,167 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior
When drawing a Difference of a subject and a clip, manim has trouble when the subject is an Intersection but only for some values of clip. With the MObjects described bellow, clip=B acts like no clip was removed, clip=A works as expected, and both Union(A,B) and Union(B,A) act like the clip was just A.

## Expected behavior
The shape on the left should appear identical to the figure on the right.

## How to reproduce the issue

Code for reproducing the problem

```py
from manim import *

class Test(Scene):
def construct(self):
unit_circle = Circle(1)
A = Circle(0.0609588680374611)
A.move_to([0.9982190504451686, 0.08529191591677689, 0])
B = Circle(0.3824675323358457)
B.move_to([0.9336555963469921, 0.5239929777210888, 0])
C = Circle(0.4540116444370362)
C.move_to([0.988647773481567, 0.47822813935857206, 0])

group = Group()
group.add( # this one is rendered wrong
Difference(
Intersection(unit_circle, C),
Union(B, A),
color=BLUE,
fill_opacity=1,
)
)
group.add( # this is rendered correctly
Intersection(
unit_circle,
Difference(C, Union(A, B)),
color=BLUE,
fill_opacity=1,
)
)
group.arrange()
self.add(group)

with tempconfig({"quality": "high_quality", "preview": True}):
scene = Test()
scene.render()
```

## Additional media files

![Test_ManimCE_v0 17 2](https://user-images.githubusercontent.com/52688444/221373063-d39dcc24-9da5-42c7-80f2-3c65ed3f0126.png)

Contributor guide

Open the contributing guide

Research direction

Start by running the provided Test scene with the stated high-quality configuration and compare the two grouped shapes. Trace the Difference, Intersection, and Union operations involved in the reproduction, then identify why nested boolean operations behave differently for these circle values. Done means the left and right shapes render identically without regressing the other demonstrated cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.