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)
Most of the internal alignment methods (when using the Cairo renderer) use the get_critical_point
method of Mobject
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
def get_critical_point(self, direction):
if np.array_equal(direction, [0, 0, 0]):
return self.custom_center
return super().get_critical_point(direction)
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.