from ..my_imports import *
from .table_general import *
__all__ = ["Table_Bh_Embedding"]
[docs]
class Table_Bh_Embedding(Table_General, Group):
"""
Class to represent a table of the coordinates of the embedding of the dark bubble.
See Table_General Class for more information. It can display the whole table
(type="together") or divided (type="split"). It has three methods (animations).
:param type: Display mode for the table. Defaults to "together".
:type type: str
:param chosen_position: The relative position of the compact dimensions with
respect to uncompact dimensions. Defaults to RIGHT.
:type chosen_position: list
.. note::
Two display types are available:
- "together": Display all 9 spatial directions in the same row.
- "split": Display compact and non-compact dimensions in two different tables.
.. code-block:: python
from manim import *
from manim_string_cosmo import *
class Example_Table_Bh_Embedding(Scene):
def construct(self):
together = Table_Bh_Embedding(type="together")
together.scale_to_fit_width(config.frame_width - 1).shift(UP)
split = Table_Bh_Embedding(type="split", chosen_position=RIGHT)
split.scale_to_fit_width(config.frame_width - 1).next_to(together, DOWN, buff=0.2)
self.add(together, split)
self.play(AnimationGroup(together.move_all(),
split.move_non_compact(),
split.move_compact()))
"""
def __init__(self, type: str = "together", chosen_position: list = RIGHT, **kwargs):
super().__init__(**kwargs)
# DEFINITION OF COORDINATES
# Coordinates
coordinates = [
"\\alpha",
"\\beta",
"\\gamma",
"\\mathcal{Z}",
"\\Theta",
"\\Psi",
"\\phi_{1}",
"\\phi_{2}",
"\\phi_{3}",
]
coordinates_non_compact = coordinates[0:4]
coordinates_compact = coordinates[4:]
coordinates_mob_non_compact = VGroup(
*[
MathTex(coordinates_non_compact[i], font_size=60)
for i in range(len(coordinates_non_compact))
]
)
coordinates_mob_compact = VGroup(
*[
MathTex(coordinates_compact[i], font_size=60)
for i in range(len(coordinates_compact))
]
)
# Dimension representation
opa_table = self.fill_opa + 0.1 # For it to be a little bit more intense.
# 4D
three_dim = VGroup(
*[
RoundedRectangle(
corner_radius=self.corner_rad,
height=1.4,
width=1.4,
color=self.hlight_1_color,
fill_opacity=2 * opa_table,
stroke_width=self.stroke_w,
)
for _ in range(3)
]
)
# Ads Throat
self.ads_dim = Line(color=self.hlight_2_color, stroke_width=0.7).rotate(PI / 4)
self.position_ads_dim = (
Dot(color=self.hlight_2_color).scale(1.5).move_to(self.ads_dim.get_start())
)
non_compact_dim = (
VGroup()
.add(*[ts for ts in three_dim])
.add(VGroup(self.ads_dim, self.position_ads_dim))
)
# Compact space
cicle = Circle(
radius=0.7, stroke_width=self.stroke_w, color=self.hlight_3_color
).rotate(-PI / 2)
position_cicle = (
Dot(color=self.hlight_3_color).scale(1.5).move_to(cicle.get_end())
)
comp = VGroup(cicle, position_cicle)
self.compact_dim = VGroup(
*[comp.copy() for _ in range(len(coordinates_mob_compact))]
)
for i in range(1, 4):
self.compact_dim[-i][-1].move_to(cicle[-1][0].get_start())
tab_non_compact = MobjectTable(
[coordinates_mob_non_compact, non_compact_dim],
line_config={"stroke_width": self.stroke_w, "color": self.decorator_color},
include_outer_lines=False,
)
box_non_compact = RoundedRectangle(
corner_radius=self.corner_rad,
height=tab_non_compact.get_height(),
width=tab_non_compact.get_width(),
stroke_width=self.decorator_stroke_w,
color=self.decorator_color,
fill_opacity=0,
).set_z_index(-3)
for i in range(4):
if i == 0:
tab_non_compact.add_highlighted_cell(
(1, i + 1),
color=self.hlight_1_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([1, 0, 0, 0])),
) # to bend only left corner
coordinates_mob_non_compact[i].set(
color=self.hlight_1_color, fill_opacity=opa_table
)
elif i == 3:
tab_non_compact.add_highlighted_cell(
(1, i + 1),
color=self.hlight_2_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([0, 0, 0, 1])),
)
coordinates_mob_non_compact[i].set(
color=self.hlight_2_color, fill_opacity=opa_table
)
else:
tab_non_compact.add_highlighted_cell(
(1, i + 1), color=self.hlight_1_color, fill_opacity=opa_table
)
coordinates_mob_non_compact[i].set(
color=self.hlight_1_color, fill_opacity=opa_table
)
tab_compact = MobjectTable(
[coordinates_mob_compact, self.compact_dim],
line_config={"stroke_width": self.stroke_w, "color": self.decorator_color},
include_outer_lines=False,
)
box_compact = RoundedRectangle(
corner_radius=self.corner_rad,
height=tab_compact.get_height(),
width=tab_compact.get_width(),
stroke_width=self.decorator_stroke_w,
color=self.decorator_color,
fill_opacity=0,
).set_z_index(-3)
for i in range(len(coordinates_mob_compact)):
if i == 0:
tab_compact.add_highlighted_cell(
(1, i + 1),
color=self.hlight_3_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([1, 0, 0, 0])),
)
coordinates_mob_compact[i].set(
color=self.hlight_3_color, fill_opacity=opa_table
)
elif i == 4:
tab_compact.add_highlighted_cell(
(1, i + 1),
color=self.hlight_3_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([0, 0, 0, 1])),
)
coordinates_mob_compact[i].set(
color=self.hlight_3_color, fill_opacity=opa_table
)
else:
tab_compact.add_highlighted_cell(
(1, i + 1), color=self.hlight_3_color, fill_opacity=opa_table
)
coordinates_mob_compact[i].set(
color=self.hlight_3_color, fill_opacity=opa_table
)
# ALL DIMENSIONS TOGETHER
self.all_dimensions = non_compact_dim.copy().add(
*[element.copy() for element in self.compact_dim.copy()]
)
self.all_coordinates = coordinates_mob_non_compact.copy().add(
*[element.copy() for element in coordinates_mob_compact.copy()]
)
tab_all = MobjectTable(
[self.all_coordinates, self.all_dimensions],
line_config={"stroke_width": self.stroke_w, "color": self.decorator_color},
include_outer_lines=False,
)
box_all = RoundedRectangle(
corner_radius=self.corner_rad,
height=tab_all.get_height(),
width=tab_all.get_width(),
stroke_width=self.decorator_stroke_w,
color=self.decorator_color,
fill_opacity=0,
).set_z_index(-3)
for i in range(9):
if i == 0:
tab_all.add_highlighted_cell(
(1, i + 1),
color=self.hlight_1_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([1, 0, 0, 0])),
)
self.all_coordinates[i].set(
color=self.hlight_1_color, fill_opacity=opa_table
)
elif i == 8:
tab_all.add_highlighted_cell(
(1, i + 1),
color=self.hlight_3_color,
fill_opacity=opa_table,
corner_radius=list(self.corner_rad[0] * np.array([0, 0, 0, 1])),
)
self.all_coordinates[i].set(
color=self.hlight_3_color, fill_opacity=opa_table
)
elif 0 < i < 3:
tab_all.add_highlighted_cell(
(1, i + 1), color=self.hlight_1_color, fill_opacity=opa_table
)
self.all_coordinates[i].set(
color=self.hlight_1_color, fill_opacity=opa_table
)
elif i == 3:
tab_all.add_highlighted_cell(
(1, i + 1), color=self.hlight_2_color, fill_opacity=opa_table
)
self.all_coordinates[i].set(
color=self.hlight_2_color, fill_opacity=opa_table
)
else:
tab_all.add_highlighted_cell(
(1, i + 1), color=self.hlight_3_color, fill_opacity=opa_table
)
self.all_coordinates[i].set(
color=self.hlight_3_color, fill_opacity=opa_table
)
if type == "together":
self.add(tab_all, box_all)
elif type == "split":
noncomp = VGroup(tab_non_compact, box_non_compact)
comp = VGroup(tab_compact, box_compact)
noncomp.next_to(comp, chosen_position)
self.add(comp, noncomp)
[docs]
def move_non_compact(
self, rt: float = 3, rf: float = rate_functions.linear
) -> Animation:
"""
Move the brane through the AdS throat.
:param rt: Run time of the animation.
:type rt: float
:param rf: Rate function of the animation.
:type rf: float
:return: Animation to move the brane along the AdS throat path.
:rtype: Animation
"""
return MoveAlongPath(
self.position_ads_dim, self.ads_dim, rate_functions=rf, run_time=rt
)
[docs]
def move_compact(
self, rt: float = 3, rf: float = rate_functions.linear
) -> AnimationGroup:
"""
Move the brane through the compact dimensions.
:param rt: Run time of the animation.
:type rt: float
:param rf: Rate function of the animation.
:type rf: float
:return: Animation group moving the brane through all compact dimensions.
:rtype: AnimationGroup
"""
return AnimationGroup(
*[
MoveAlongPath(
self.compact_dim[-i][-1],
self.compact_dim[-i][0],
rate_functions=rf,
run_time=rt,
)
for i in range(1, 4)
]
)
[docs]
def move_all(
self, rt: float = 3, rf: float = rate_functions.linear
) -> AnimationGroup:
"""
Move the brane through all coordinates.
:param rt: Run time of the animation.
:type rt: float
:param rf: Rate function of the animation.
:type rf: float
:return: Animation group moving the brane through all spatial coordinates.
:rtype: AnimationGroup
"""
return AnimationGroup(
*[
MoveAlongPath(
self.all_dimensions[-i][-1],
self.all_dimensions[-i][0],
rate_functions=rf,
run_time=rt,
)
for i in range(1, 4)
],
MoveAlongPath(
self.all_dimensions[3][-1],
self.all_dimensions[3][0],
rate_functions=rf,
run_time=rt,
),
)