Aggregate relations between geometric figures, a fundamental concept in mathematics and geometry, the
By calculating relationships such as intersection and concurrency of different shapes (e.g., circles, rectangles, triangles, etc.), it is possible to realize complex graphic processing and visual effects.
manim
It is provided in the4 typesA module to compute aggregate relationships between geometric shapes:
-
Difference
: fromShape ASubtract fromShape Bintersection -
Exclusion
: MinusShape Acap (a poem)Shape BIntersecting parts, retaining different parts -
Intersection
: Preserve the intersection between all shapes -
Union
: Preserve the concatenation of all shapes
1. Main parameters
Difference
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
subject | VMobject | Primary display geometry |
clip | VMobject | Geometry used for cutting |
Difference
that is, willsubject
cap (a poem)clip
The intersecting parts are fromsubject
Delete from the list.
Exclusion
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
subject | VMobject | The first geometry |
clip | VMobject | Second geometry |
Exclusion
that is, willsubject
cap (a poem)clip
Delete the intersecting parts and keepsubject
cap (a poem)clip
Remainder.
Intersection
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
vmobjects | *VMobject | Can be passed in 2 or more geometries |
Intersection
It is the part that preserves all geometry intersections.
If the parametervmobjects
An error is reported if the number of geometries in a geometry is less than 2.
Union
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
vmobjects | *VMobject | Can be passed in 2 or more geometries |
Union
is the part that preserves all the geometry together.
If the parametervmobjects
An error is reported if the number of geometries in a geometry is less than 2.
2. Examples of use
manim provides a collection of relational modules that greatly simplify the writing of code.
2.1 Difference Example
subject = Square()
clip = Circle()
Difference(subject, clip)
2.2 Exclusion Example
subject = Square()
clip = Circle()
Exclusion(subject, clip)
2.3. Intersection example
subject = Square()
clip = Circle()
Intersection(subject, clip)
2.4 Union example
subject = Square()
clip = Circle()
Union(subject, clip)
3. Annexes
The complete code for the article is on a web disk (bool_ops.py
),
Download at.Full Code (Access code: 6872)