Location>code7788 >text

manim learning-by-doing - set relations between graphs

Popularity:253 ℃/2024-09-27 13:00:53

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.

manimIt is provided in the4 typesA module to compute aggregate relationships between geometric shapes:

  1. Difference: fromShape ASubtract fromShape Bintersection
  2. Exclusion: MinusShape Acap (a poem)Shape BIntersecting parts, retaining different parts
  3. Intersection: Preserve the intersection between all shapes
  4. Union: Preserve the concatenation of all shapes

1. Main parameters

DifferenceThe main parameters are:

Parameter name typology clarification
subject VMobject Primary display geometry
clip VMobject Geometry used for cutting

Differencethat is, willsubjectcap (a poem)clipThe intersecting parts are fromsubjectDelete from the list.

ExclusionThe main parameters are:

Parameter name typology clarification
subject VMobject The first geometry
clip VMobject Second geometry

Exclusionthat is, willsubjectcap (a poem)clipDelete the intersecting parts and keepsubjectcap (a poem)clipRemainder.

IntersectionThe main parameters are:

Parameter name typology clarification
vmobjects *VMobject Can be passed in 2 or more geometries

IntersectionIt is the part that preserves all geometry intersections.

If the parametervmobjectsAn error is reported if the number of geometries in a geometry is less than 2.

UnionThe main parameters are:

Parameter name typology clarification
vmobjects *VMobject Can be passed in 2 or more geometries

Unionis the part that preserves all the geometry together.

If the parametervmobjectsAn 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)