arc polygonIt's a combination ofcircular arccap (a poem)polygonalof shapes, this type of geometry is very widely used in design.
For example, in home design, look at the home of the sofa, dining table and seats, their corners, backrests and other places are curved design, this design effectively softens the interior space, so that the overall atmosphere is more harmonious and natural.
There are also landscape and architectural designs where curved polygons are often used for road planning, flower bed layouts, and so on.
Especially the children's play area, through the free arc design, not only in line with the children's lively and active nature, but also to stimulate their imagination and creativity.
In the field of art and design, curved polygons are used more often, in the creation of graphics, logos, posters, etc., the unique shape and visual effect of curved polygons can attract the attention of the audience, and convey the designer's intentions and emotions.
manim
There are 2 modules provided to construct curved polygons:
-
ArcPolygon
: ByVertex and radianto construct curved polygons -
ArcPolygonFromArcs
: Bycircular arcto construct curved polygons
The main difference between these two modules is the construction of the curved polygonalThe process is different, one through the vertices and one through the arcs.
The final constructed curved polygon is no different.
1. Main parameters
ArcPolygon
The main parameters are:
Parameter name | typology | clarification |
---|---|---|
vertices | Point3D | List of vertices of a polygon |
angle | float | Set the radian of all arcs uniformly |
radius | float | Set the radius of all arcs uniformly |
arc_config | list[dict] | Set the radian of each arc separately |
verticevertices
After determining thatangle
cap (a poem)radius
Sets the degree of curvature of the arc between every two vertices.
angle
cap (a poem)radius
Only one parameter can be used, and if both are used, theangle
The parameter is invalid.
angle
cap (a poem)radius
is to set the radians of all arcs of a polygon uniformly.arc_config
You can set each arc to have a different radian.
ArcPolygonFromArcs
The parameters are relatively simple.
Parameter name | typology | clarification |
---|---|---|
arcs | Arc | set of arcs |
Note that if the parameter is passed in as an arc listarcs
cannot form a closed polygon.
So.manim
will automatically associatearcs
The end point of the last arc in the center is connected to the start point of the first arc with a straight line to form a closed polygon.
These two modules (ArcPolygon
cap (a poem)ArcPolygonFromArcs
) There is no difference between the constructed arc polygons, and different modules are selected according to the actual situation when creating the animation.
If vertex information is available, then useArcPolygon
to construct the polygon, and if there is information about the individual arcs, then use theArcPolygonFromArcs
to construct polygons.
2. Examples of use
2.1 Harmonization of the setting of arcs
utilizationangle
You can set the radian of each edge in an arc polygon uniformly; the larger the radian is set, the more curved the edge will be.
vertices = [UR, UL, DL, DR]
ArcPolygon(*vertices, angle=0)
ArcPolygon(*vertices, angle=60 * DEGREES)
ArcPolygon(*vertices, angle=120 * DEGREES)
2.2 Harmonization of radii
utilizationradius
It is also possible to set the curvature of each edge in an arc polygon.radius
is the radius of the circle in which the two vertices forming the arc are located.
the reason whyradius
The larger it is, the less curvature of the edge.
vertices = [UR, UL, DL, DR]
ArcPolygon(*vertices, radius=10)
ArcPolygon(*vertices, radius=1)
ArcPolygon(*vertices, radius=2)
2.3. set up each arc separately
parametersangle
cap (a poem)radius
is used to set the curvature of all edges uniformly.
If we want to set a different radian for each side of an arc polygon, we have to use thearc_config
Parameters.
vertices = [UR, UL, DL, DR]
arc_config = [
{"angle": 30 * DEGREES},
{"angle": 90 * DEGREES},
{"radius": 2},
{"radius": 5},
]
ArcPolygon(*vertices, arc_config)
pass (a bill or inspection etc)arc_config
Not only can you set the curvature of each arc, but you can also set their line thickness, color, and other properties.
2.4 Constructing polygons from arcs
ArcPolygonFromArcs
is constructing the polygon from a series of arcs, so there is no need for theangle
cap (a poem)radius
These parameters are up.
This is because the curvature and related properties of the arcs are already set when each arc is constructed.
arc1 = ArcBetweenPoints(
angle=PI / 6, # 30degree (angles, temperature etc)
color=BLUE,
)
arc2 = ArcBetweenPoints(
angle=PI / 3, # 60degree (angles, temperature etc)
color=GREEN,
)
arc3 = ArcBetweenPoints(
angle=PI / 2, # 90degree (angles, temperature etc)
color=YELLOW,
)
arc4 = ArcBetweenPoints(
angle=2 * PI / 3, # 120degree (angles, temperature etc)
color=RED,
)
ArcPolygonFromArcs(arc1, arc2, arc3, arc4)
2.5 Polygons with missing arcs
The above example uses theArcPolygonFromArcs
When constructing a polytope, the incoming 4 arcs together are exactly closed.
What happens if the incoming arc is not closed?
ArcPolygonFromArcs
will automatically connect the non-closed parts with straight lines.
That is, the end point of the previous arc is connected to the start point of the next arc by a straight line, eventually forming a closed polygon.
arc1 = ArcBetweenPoints(
angle=PI / 6, # 30degree (angles, temperature etc)
color=BLUE,
)
arc3 = ArcBetweenPoints(
angle=PI / 2, # 90degree (angles, temperature etc)
color=YELLOW,
)
ArcPolygonFromArcs(arc1, arc3)
The missing part is the part connected by the white straight line above.
3. Annexes
The complete code for the article is on a web disk (arc_polygon.py
),
Download at.Full Code (Access code: 6872)