title: “Mesh Topology Animation” format: revealjs editor: visual —
Introduction
Mesh topology is a network structure where each device connects directly to multiple others, ensuring high redundancy and reliability. Unlike star or bus topologies, mesh allows continuous communication even if one link fails, making it ideal for critical applications. In modern industries—such as telecommunications, defense systems, and smart infrastructure—mesh topology enhances data integrity, fault tolerance, and scalability. It’s particularly relevant in wireless networks and IoT deployments, where decentralized control and resilient data pathways are essential. Though complex and costly to implement fully, partial mesh networks strike a balance between performance and efficiency, making them highly practical in today’s connected world.
Importing Required Libraries
from manim import *
import numpy as np
import random
manim
: Core library for animations.numpy
: For mathematical operations, especially trigonometry.random
: To randomly select network nodes during animation.
Step 1: Create the 3D Pyramid (Server)
def create_pyramid(self):
= 1
height = 0.8
base_size
= np.array([-base_size/2, -base_size/2, 0])
v1 = np.array([base_size/2, -base_size/2, 0])
v2 = np.array([base_size/2, base_size/2, 0])
v3 = np.array([-base_size/2, base_size/2, 0])
v4 = np.array([0, 0, height])
apex
= VGroup(
faces
Triangle().set_points_as_corners([apex, v1, v2]).set_color(GREEN),
Triangle().set_points_as_corners([apex, v2, v3]).set_color(GREEN),
Triangle().set_points_as_corners([apex, v3, v4]).set_color(GREEN),
Triangle().set_points_as_corners([apex, v4, v1]).set_color(GREEN),
Polygon(v1, v2, v3, v4).set_color(GREEN)
)return faces
- Creates a 3D pyramid to act as the main server.
- Uses triangles for the sides and a polygon for the base.
- All elements are colored green to visually distinguish the server.
Step 2: Scene Setup
self.set_camera_orientation(phi=75*DEGREES, theta=-45*DEGREES)
Adjusts the initial camera angle for a better 3D perspective.
Add Title
= Text("Mesh Topology Animation", font_size=24, color=BLUE).to_edge(UP*0.5)
title self.add_fixed_in_frame_mobjects(title)
- Adds a static title to the top of the screen.
- Does not rotate or move with the 3D scene.
Step 3: Create PCs (End Devices)
= 4
radius = VGroup()
pcs = VGroup()
pc_labels
for i in range(10):
= i * (2*PI/10)
angle = radius * np.cos(angle)
x = radius * np.sin(angle)
y = np.sin(angle) * 0.5
z
= Cube(side_length=0.4).set_color(BLUE)
pc
pc.move_to([x, y, z])
pcs.add(pc)
= Text(f"PC{i+1}", font_size=16)
label
label.next_to(pc, DOWN)=OUT)
label.rotate(angle, axis pc_labels.add(label)
- Places 10 PC cubes evenly around a circle using trigonometry.
- Each PC is labeled and placed with a small Z-offset for 3D appearance.
Step 4: Create Routers
= VGroup()
routers = VGroup()
router_labels
for i in range(2):
= i * (2*PI/2)
angle = (radius*0.5) * np.cos(angle)
x = (radius*0.5) * np.sin(angle)
y = 1
z
= Sphere(radius=0.2).set_color(RED)
router
router.move_to([x, y, z])
routers.add(router)
= Text(f"R{i+1}", font_size=18)
label
label.next_to(router, UP) router_labels.add(label)
- 2 routers placed closer to the center, elevated for distinction.
- Red spheres represent routers.
Step 5: Create Server
= self.create_pyramid()
server
server.set_color(GREEN)0, 0, 2])
server.move_to([= Text("Main Server", font_size=20).next_to(server, UP) server_label
- Server placed above routers at Z = 2.
- Reuses earlier
create_pyramid()
function.
Step 6: Create Connections
def create_connections(start_objects, end_objects, bandwidth_type='high'):
...
- Defines a reusable function for creating lines between elements.
- Supports 3 types of bandwidth:
- high (orange, thick)
- medium (yellow, medium)
- low (light blue, thin)
Apply Connections
= create_connections(pcs, routers, 'medium')
pc_router_connections = create_connections(routers, routers, 'high')
router_router_connections = create_connections(routers, [server], 'high') server_connections
Connects: - PCs ↔︎ Routers - Routers ↔︎ Routers - Routers ↔︎ Server
Animate Creation
self.play(Create(pcs), Write(pc_labels), run_time=7)
for router, label in zip(routers, router_labels):
self.play(Create(router), Write(label), Flash(router.get_center(), color=GREY), run_time=3)
self.play(Create(server), Write(server_label), Flash(server.get_center(), color=GREEN), run_time=1.5)
- Sequential creation of PCs, routers, and server.
- Flashes emphasize importance of nodes.
Animate Connections
self.play(Create(pc_router_connections), run_time=6)
self.wait(0.5)
self.play(Create(router_router_connections), run_time=3)
self.play(Create(server_connections), run_time=3)
- Connections appear after nodes are placed.
- Wait time allows viewers to absorb each step.
Camera Movements
self.begin_ambient_camera_rotation(rate=0.1)
self.wait(3)
self.stop_ambient_camera_rotation()
self.move_camera(phi=45 * DEGREES, theta=45 * DEGREES, run_time=4)
- Adds camera motion to increase immersion.
- Rotates around the mesh for full visualization.
Simulate Data Flow
for _ in range(2):
= Sphere(radius=0.1).set_color(WHITE)
packet = random.choice(pcs)
start_pc = random.choice(routers)
mid_router
self.play(packet.animate.move_to(start_pc.get_center()), run_time=3)
self.play(packet.animate.move_to(mid_router.get_center()), run_time=3)
self.play(packet.animate.move_to(server.get_center()), run_time=3)
self.play(FadeOut(packet), run_time=1)
- Simulates network packets traveling:
- From a random PC
- Through a random router
- To the main server
Final Camera Views
self.move_camera(phi=45 * DEGREES, theta=(360+45) * DEGREES, ...)
self.move_camera(phi=0 * DEGREES, ...)
self.move_camera(phi=180 * DEGREES, ...)
- Rotates the camera to view from multiple angles.
Cleanup Scene
self.play(*[FadeOut(mob) for mob in self.mobjects], run_time=5, rate_func=rate_functions.smooth)
- Smoothly fades out all objects to end the animation cleanly.
Summary
Created a 3D network with: - PCs - Routers - Server - Connections - Data packets
Used Manim’s 3D capabilities and camera tools.
Highlighted modular design (reusable functions).