在 manim 中对齐不对称多边形
我学会了在 Manim 中绘制(通过顶点)一些不对称的多边形。 (如果重要的话,我关心的形状是此图表中的值“longa”、“brevis”、“semibrevis”和“minima”:https://upload.wikimedia.org/wikipedia/commons/a/a5/MensuralNotation.JPG )
其中一些是对称形状(如 ♢ 或 □),易于在 manim 中对齐和操作。然而,有些是不对称的(如“p”或“d”),但它们的中心/旋转轴/对齐点不是顶点中心,而是另一个点(如“p”的碗的中心)或“d”)。
我想要一系列像“p ♢ □ d”这样的VMobjects都在它们定义的中心对齐(对于“p”和“d”,我构建了多边形,以便它们的原点应该是中心)。我尝试过覆盖 get_center()
并尝试将对象与 ORIGIN 对齐,但是(即使在执行 .shift()
后)所有对象都分配给align_to、next_to 等和围绕该对象的 VGroup 都忽略中心。
有没有一种方法可以更有力地为对象分配中心?
(Manim 社区分叉,最新截至 2022 年 3 月 10 日)
I've learned to draw (via verticies) a number of asymmetrical polygons in Manim. (if it matters, the shapes I'm concerned with are the values "longa", "brevis", "semibrevis" and "minima" in this chart: https://upload.wikimedia.org/wikipedia/commons/a/a5/MensuralNotation.JPG
)
Some of them are symmetrical shapes (like ♢ or □) which are easy to align and manipulate in manim. Some however are asymmetrical (like "p" or "d") but their center/axis-of-rotation/point-of-alignment are not the center of vertices but another point (like the center of the bowl of the "p" or "d").
I'd like to have a series of VMobjects like "p ♢ □ d" all align on their defined centers (for "p" and "d" I constructed the polygons so that their origins should be the center). I've tried overriding get_center()
and trying to align objects to the ORIGIN but (even after performing a .shift()
) all objects assigned to align_to, next_to, etc. and a VGroup surrounding the object all ignore the center.
Is there a way to more forcefully assign the center for an object?
(Manim community fork, latest as of March 10, 2022)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大多数内部对齐方法(使用 Cairo 渲染器时)使用
get_ritic_point
方法Mobject
来确定应用于对齐的 mobject 的特殊点。如果您想采用覆盖方法,那么我建议您覆盖该方法。如果它确实只是您想要覆盖的自定义中心,那么类似的东西
可能已经可以工作了。
不过,这可能会破坏其他一些东西,所以我不能完全确定整体上是否更好地实现和使用某种自定义辅助函数来进行对齐,然后使用它们。
Most of the internal alignment methods (when using the Cairo renderer) use the
get_critical_point
method ofMobject
to determine the special points of a mobject that should be used for alignment. If you'd like to pursue your override-approach, then I'd recommend overriding that one.If it is really just the custom center you would like to override, then something like
might already work.
It is possible that this breaks some other things though, so I can't quite tell whether it would be better overall to just implement and use some sort of custom auxiliary functions for alignment and then work with those.