A circular shape can be considered a special kind of circle that is part of a circle.manim
in which several modules are packaged separately for circular shapes:
-
Arc
: Generalized arcs, drawing arcs based on radius and angle -
ArcBetweenPoints
: Drawing arcs based on two points and angles -
AnnularSector
: a circular arc that is equivalent to being part of a circle -
Sector
: scalloped, always 1/4 circle.
Among them.ArcBetweenPoints
cap (a poem)AnnularSector
inherited fromArc
,Sector
inherited fromAnnularSector
。
Circular Arc SeriesThe module is located in themanim
hit the nail on the headMobject
Under.
1. Main parameters
module (in software)Arc
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
radius | float | radius of a circular arc |
start_angle | float | The arc of the beginning of the circle |
angle | float | Curvature of the arc |
num_components | int | The segments that make up an arc. The larger the value, the more rounded the arc is. |
arc_center | Point3D | The position of the center of the circle corresponding to the arc |
The start and end points of a circular arc are determined by thestart_angle
cap (a poem)angle
Controlled.start_angle
parameter controls the starting point of the arc, the default value is0
(The right side of the center of the circle is0 degrees);angle
parameter is the radian of the arc.start_angle + angle
The value of is the endpoint of the arc, theangle
is calculated counterclockwise.
module (in software)ArcBetweenPoints
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
start | Point3D | Starting point of the arc |
end | Point3D | end of a circular arc |
angle | float | Curvature of the arc |
raduis | float | radius of a circular arc |
This module is based on two points (start
cap (a poem)end
) to draw arcs.angle
cap (a poem)raduis
Only one parameter can be set to control the arc length of the arc.start
cap (a poem)end
Fixed whenangle
The larger it is, the longer the arc length;raduis
The larger it is, the shorter the arc length.
module (in software)AnnularSector
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
inner_radius | float | Inner radius of a circular arc |
outer_radius | float | Outer radius of circular arc |
start_angle | float | The arc at the beginning of a circular arc |
angle | float | The curvature of the circular arc |
inner_radius
cap (a poem)outer_radius
The difference formed a loop;start_angle
cap (a poem)angle
Meaning and ModuleArc
The same as the parameter of the same name in the
module (in software)Sector
The main parameters of the
Parameter name | typology | clarification |
---|---|---|
inner_radius | float | Inner radius of a circular arc |
outer_radius | float | Outer radius of circular arc |
Sector
Module onlyinner_radius
cap (a poem)outer_radius
two parameters, since it defaults to 1/4 of a circle.
2. Main approaches
The role of these modules is mainly to display graphics, so there are not many methods, and two are commonly used:
name (of a thing) | clarification |
---|---|
get_arc_center | Get the coordinates of the current center of the arc. |
move_arc_center_to | Setting the coordinates of the new center of the arc |
3. Examples of use
The following demonstrates some examples for the parameters of each of the 4 circular shaped modules.
3.1 Generalized arcs
Generalized arcsArc
is the most commonly used.start_angle
cap (a poem)angle
Sets the starting point and radian of the arc.arc_center
Sets the position of the arc.radius
Controls the size of the arc.
Arc(
arc_center=LEFT * 2,
angle=PI,
)
Arc(
radius=1.5,
arc_center=RIGHT,
angle=PI,
)
Arc(
start_angle=PI / 2,
angle=PI / 2,
arc_center=LEFT * 2 + DOWN * 2,
)
Arc(
start_angle=PI,
angle=PI * 3 / 2,
arc_center=RIGHT + DOWN * 1.5,
)
3.2 Generating arcs from two points
Generate arcs from fixed two pointsArcBetweenPoints
is also commonly used when creating animations.
parametersstart
cap (a poem)end
Sets the start and end points of the arc;angle
cap (a poem)radius
Sets the degree of curvature of the arc, only one of these two parameters can be used, and when set at the same time only theradius
be born
ArcBetweenPoints(
start.get_center(),
end.get_center(),
radius=0.8,
)
ArcBetweenPoints(
start.get_center(),
end.get_center(),
radius=1.6,
)
ArcBetweenPoints(
start.get_center(),
end.get_center(),
angle=PI / 2,
)
ArcBetweenPoints(
start.get_center(),
end.get_center(),
angle=PI,
)
The first two examples useradius
to control the degree of the arc, the last two examples use theangle
Controls the degree of the arc.
3.3. Arc of the ring
Circular ArcAnnularSector
It can be interpreted as an arc with increased thickness.
It can be usedArc
parameter, which differs in that it has two radii, ainner_radius
One isouter_radius
。
The difference between these two radii is the thickness of the ring.
AnnularSector(
inner_radius=0.5,
outer_radius=1.5,
angle=PI,
)
AnnularSector(
inner_radius=0.5,
outer_radius=0.8,
angle=PI,
)
AnnularSector(
start_angle=PI / 2,
angle=PI / 2,
inner_radius=0.5,
outer_radius=1.5,
)
AnnularSector(
start_angle=PI,
angle=PI * 3 / 2,
inner_radius=0.5,
outer_radius=0.8,
)
3.4. Sector
sectorSector
It is a simplifiedAnnularSector
It is fixed to1/4
A circle.
Sector(
inner_radius=0.5,
outer_radius=1.5,
)
Sector(
inner_radius=0.5,
outer_radius=0.8,
)
Sector(
inner_radius=1,
outer_radius=1.5,
)
Sector(
inner_radius=0.3,
outer_radius=1.8,
)
4. Annexes
The complete code for the article is on a web disk (),
Download at.Full Code (Access code: 6872)