Replies: 3 comments 1 reply
-
Why is it so difficult to follow the given template when creating an issue report here on Github - especially when it comes to correctly inserting the code?
Because for Manim the center of all objects is the center of an invisible, rectangular bounding box around the object. When you say center of the triangle, I assume you mean the center of mass, which is most commonly wanted. In Manim you this with But you should be aware that there are a couple of more centers of a triangle: the center of the incircle, the center of the outcircle,... class GraphicSegmentation(Scene):
def construct(self):
tir=Triangle().scale(3)
vertexs=tir.get_vertices()
dotO=tir.get_center_of_mass()
group=VGroup(
[
Polygon(
vertexs[i],vertexs[(i+1)%3], dotO,
fill_color=c,
fill_opacity=0.5
)
for i,c in enumerate([RED, GREEN, YELLOW])
]
)
self.add(tir)
self.add(group)
bounding_box = VGroup(
Polygon(
*[tir.get_critical_point(p) for p in [UR,UL,DL,DR]],
),
Line(tir.get_critical_point(UR),tir.get_critical_point(DL)),
Line(tir.get_critical_point(UL),tir.get_critical_point(DR)),
).set_stroke(color=RED,width=1)
self.add(bounding_box) |
Beta Was this translation helpful? Give feedback.
-
I'm a novice. Thank you very much
----- 原始邮件 -----
发件人:Uwe Zimmermann ***@***.***>
收件人:ManimCommunity/manim ***@***.***>
抄送人:jmath ***@***.***>, Author ***@***.***>
主题:Re:_[ManimCommunity/manim]_Why_isn't_‘get_center()’_at_the_center_of_the_triangle?_(Discussion_#4221)
日期:2025年04月18日 20点52分
Why is it so difficult to follow the given template when creating an issue report here on Github - especially when it comes to correctly inserting the code?
Why isn't ‘get_center()’ at the center of the triangle?
Because for Manim the center of all objects is the center of an invisible, rectangular bounding box around the object.
When you say center of the triangle, I assume you mean the center of mass, which is most commonly wanted. In Manim you this with .get_center_of_mass().
But you should be aware that there are a couple of more centers of a triangle: the center of the incircle, the center of the outcircle,...
https://en.wikipedia.org/wiki/Triangle_center
class GraphicSegmentation(Scene):
def construct(self):
tir=Triangle().scale(3)
vertexs=tir.get_vertices()
dotO=tir.get_center_of_mass()
group=VGroup(
[
Polygon(
vertexs[i],vertexs[(i+1)%3], dotO,
fill_color=c,
fill_opacity=0.5
)
for i,c in enumerate([RED, GREEN, YELLOW])
]
)
self.add(tir)
self.add(group)
bounding_box = VGroup(
Polygon(
*[tir.get_critical_point(p) for p in [UR,UL,DL,DR]],
),
Line(tir.get_critical_point(UR),tir.get_critical_point(DL)),
Line(tir.get_critical_point(UL),tir.get_critical_point(DR)),
).set_stroke(color=RED,width=1)
self.add(bounding_box)
image.png (view on web)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Come over to Discord for questions like these - it's easy that they drown here on Github: |
Beta Was this translation helpful? Give feedback.
-
from manim import *
class GraphicSegmentation(Scene):
def construct(self):
tir=Triangle().scale(3)
vertexs=tir.get_vertices()
# dot=VGroup([Dot(vertex) for vertex in vertexs])
# self.play(Create(dot))
# self.wait(1)
dotO=tir.get_center()
# dotO=sum(vertexs)/3
group=VGroup([Polygon(vertexs[i],
vertexs[(i+1)%3], dotO,
fill_color=c,
fill_opacity=0.5
)
for i,c in enumerate([RED, GREEN, YELLOW])])
self.play(Create(tir))
self.wait(1)
self.play(Create(group))
self.wait(1)
Beta Was this translation helpful? Give feedback.
All reactions