Polygon¶
- class Polygon(*points: Sequence[Point], disk: Disk, **kwargs)[source]¶
The Poincaré disk equivalent to Manim’s Polygon, connecting a sequence of points with geodesic lines.
Examples
Example: PolygonExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon class PolygonExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon)
from hmanim.poincare import Disk, Point, Polygon class PolygonExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon)
- get_sides() list[Line] [source]¶
Returns a list of the lines representing sides of the polygon.
- Returns:
- The lines representing the sides of
the polygon.
- Return type:
- rotated_by(angle: float) Polygon [source]¶
Rotates the polygon by the given angle in radians around the origin.
- Parameters:
angle (float) – The angle to rotate the polygon by.
- Returns:
The rotated polygon.
- Return type:
Examples
Example: PolygonRotatedByExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon class PolygonRotatedByExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ).rotated_by(TAU / 8) self.add(polygon)
from hmanim.poincare import Disk, Point, Polygon class PolygonRotatedByExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ).rotated_by(TAU / 8) self.add(polygon)
- translated_by(distance: float) Polygon [source]¶
Translates the polygon by the given distance in positive x-direction. A negative distance will translate the polygon in the negative x-direction.
- Parameters:
distance (float) – The distance to translate the polygon by.
- Returns:
The translated polygon.
- Return type:
Examples
Example: PolygonTranslatedByExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon class PolygonTranslatedByExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ).translated_by(1.0) self.add(polygon)
from hmanim.poincare import Disk, Point, Polygon class PolygonTranslatedByExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ).translated_by(1.0) self.add(polygon)
- class PolygonRotate(mobject=None, *args, use_override=True, **kwargs)[source]¶
A rotation around the origin by the passed angle.
Examples
Example: PolygonRotateExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon, PolygonRotate class PolygonRotateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonRotate( polygon, angle=TAU / 8, run_time=3, ), )
from hmanim.poincare import Disk, Point, Polygon, PolygonRotate class PolygonRotateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonRotate( polygon, angle=TAU / 8, run_time=3, ), )
- interpolate_mobject(alpha: float) None [source]¶
Interpolates the mobject of the
Animation
based on alpha value.- Parameters:
alpha – A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.
- class PolygonRotatedTranslate(mobject=None, *args, use_override=True, **kwargs)[source]¶
A ‘translation’ by the passed distance along an axis that is rotated away from the x-axis by the passed angle.
Examples
Example: PolygonRotatedTranslateExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon, PolygonRotatedTranslate class PolygonRotatedTranslateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonRotatedTranslate( polygon, distance=1, angle=TAU / 8, run_time=3, ), )
from hmanim.poincare import Disk, Point, Polygon, PolygonRotatedTranslate class PolygonRotatedTranslateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonRotatedTranslate( polygon, distance=1, angle=TAU / 8, run_time=3, ), )
- interpolate_mobject(alpha: float) None [source]¶
Interpolates the mobject of the
Animation
based on alpha value.- Parameters:
alpha – A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.
- class PolygonTranslate(mobject=None, *args, use_override=True, **kwargs)[source]¶
A ‘translation’ along the x-axis by the passed distance.
Examples
Example: PolygonTranslateExample ¶
from manim import * from hmanim.poincare import Disk, Point, Polygon, PolygonTranslate class PolygonTranslateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonTranslate( polygon, distance=1, run_time=3, ), )
from hmanim.poincare import Disk, Point, Polygon, PolygonTranslate class PolygonTranslateExample(Scene): def construct(self): disk = Disk( radius=3, color=WHITE, ) self.add(disk) polygon = Polygon( Point(-0.75, 0.0), Point(0.0, 0.75), Point(0.75, 0.0), Point(0.0, -0.75), disk=disk, color=BLUE, ) self.add(polygon) self.play( PolygonTranslate( polygon, distance=1, run_time=3, ), )
- interpolate_mobject(alpha: float) None [source]¶
Interpolates the mobject of the
Animation
based on alpha value.- Parameters:
alpha – A float between 0 and 1 expressing the ratio to which the animation is completed. For example, alpha-values of 0, 0.5, and 1 correspond to the animation being completed 0%, 50%, and 100%, respectively.