Skip to content

Shubham18024/Python-Mathematical-Animation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Python Mathematical Animation

Python NumPy Matplotlib UV Platform

A collection of mathematical animations built with Python to help students visualize mathematical concepts using geometry, linear algebra, and transformations.

This project demonstrates how mathematical ideas can be turned into dynamic visual animations using libraries such as NumPy and Matplotlib.

The focus of this repository is learning mathematics through visualization and understanding how mathematical transformations produce motion.


Project Goals

This project aims to help students understand:

  • Mathematical visualization
  • Coordinate geometry
  • Linear transformations
  • Rotation matrices
  • Parametric motion
  • 2D and 3D animation principles

Instead of treating animation as a graphics trick, the project approaches animation as a mathematical transformation problem.


Demo Animations

2D Animation

Cat Ladder Animation

A classical geometric construction visualized dynamically.

Cat Ladder Animation


3D Animations

Catenoid → Helicoid Transformation

Minimal surfaces catenoid and helicoid are isometric and can smoothly deform into each other without stretching.

C-H-TRANS


Boy’s Surface

Boy’s Surface is an immersion of the real projective plane $RP^2$ into $R^3$ discovered by Werner Boy in 1901.

BOYS SURFACE


Human Body Movement

Multiple Shapes combine to perform human movement.

Human Movement


Translation + Rotation

Multiple cubes are translating and rotating.

Cube Translate and Movement


Rotating Cube with faces and its explosion into individual faces

Updation of CUBE from wireframe to surface plot which gets explodes to individual faces and reassemble.

Rotating Cube With Faces


Rotating Sphere

Animation showing multiple Sphere in and their rotation in different axes.

Rotating Spheres


Rotating Camera Angle

Animation showing how the camera viewpoint changes while the object itself remains fixed.
This demonstrates the difference between camera motion and object motion in 3D visualization.

Rotating Camera


Rotating Triangle

A triangle rotating using a rotation matrix.

Triangle Rotation


Rotating Square

A square rotating around the x-axis.

Square Rotation


Rotating Cube

A cube rotating using combined 3D transformations.

Cube Rotation


Mathematical Idea Behind the Animations

Most animations in this project are based on linear algebra transformations.

Example transformation:

P' = R @ P

Where

  • P = original coordinates
  • R = transformation matrix
  • P' = transformed coordinates

For example, a rotation around the z-axis is given by

Rz(θ) = [[cosθ  -sinθ  0]
         [sinθ   cosθ  0]
         [0        0   1]]

Applying this matrix rotates every point of an object simultaneously.


Repository Structure

.
├── 2d-anim
│   ├── notebooks
│   ├── scripts
│   └── assets
│       ├── gifs
│       └── videos
│
├── 3d-anim
│   ├── notebooks
│   ├── scripts
│   └── assets
│       ├── gifs
│       └── videos

Installation

This project uses uv for Python environment and dependency management.

Install uv (if not installed):

pip install uv

Clone the repository:

git clone https://github.com/Shubham18024/Python-Mathematical-Animation.git
cd Python-Mathematical-Animation

or using SSH(if you have SSH keys configured)

git clone git@github.com:Shubham18024/Python-Mathematical-Animation.git
cd Python-Mathematical-Animation

Install dependencies using uv:

uv sync

This command will:

  • create the virtual environment
  • install dependencies from pyproject.toml

Running Examples

Run scripts using uv:

uv run python 3d-anim/scripts/object_rotation.py

Example:

uv run python 3d-anim/scripts/rotating_camera.py

To open notebooks:

uv run jupyter lab

Author

Shubham Tiwari

B.Sc. Mathematics (Hons)

Dyal Singh College

University of Delhi


License

This project will be released under the MIT License.