Skip to content

Latest commit

Β 

History

93 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

triangulateMe πŸ“βœπŸ‘½

An interactive computational geometry playground built with Three.js. Draw polygons and obstacles directly on the screen and watch classic computational geometry algorithms run step by step, with visualizations and explanations for each stage.

β–Ά Live Demo: defnetuncer98.github.io/triangulateMe

Developed as part of the Computer Graphics MSc program at Hacettepe University.

πŸ¦– Fun fact: This project was written entirely by hand, before AI coding assistants were a thing. Every intersection test, every diagonal, every off-by-one bug β€” 100% organic, free-range, human-made code. πŸ™‚

Modules

The app consists of three interactive modules, each demonstrating a different problem:

1. πŸ”Ί Polygon Triangulation by Graph Coloring

Click to draw a simple polygon, then watch it get triangulated in three visualized steps:

Step What happens Complexity
1. Find Orientation The rightmost vertex (on the convex hull) is located and the sign of its angle determines whether the polygon is clockwise or counter-clockwise O(n)
2. Internal Diagonals All candidate diagonals are tested: convex/reflex angle check, in-cone (internality) test, and edge intersection test β€”
3. Two-Coloring the Graph A graph is built where each diagonal is a node and intersecting diagonals share an edge. The graph is greedily two-colored; the "white" diagonals form a valid triangulation β€”

2. ⚑ Motion Planning

Find a safe path for a point agent moving on a plane with line segment obstacles:

Step What happens Complexity
1. Fat Triangulation A Delaunay triangulation is generated from the obstacle endpoints and the plane's corners O(n log n)
2. Weighted Graph Edge midpoints of the triangulation become graph nodes (adjacency list). Paths crossing obstacles are pruned; source and target points are added O(nΒ²)
3. Shortest Path Dijkstra's algorithm finds the shortest obstacle-avoiding path from source to target O(nΒ²)

3. 🧊 2D Shadow

Compute which parts of a polygon are lit when light comes from all directions outside it:

Step What happens Complexity
1. Light Rays Rays are shot between vertex pairs; a vertex is in the light if at least one unblocked exterior ray reaches it, otherwise it's in the shadow. Ray-boundary intersections add new light vertices on the edges O(nΒ³)
2. Removing Shadow Vertices Shadowed vertices are removed to produce the new lit boundary O(n)
3. Point Insertion Click to add points β€” a ray-crossing (even–odd) test decides whether each point falls in the light zone or the shadow zone O(n)

Running Locally

No build step or dependencies to install β€” it's plain HTML/CSS/JavaScript with Three.js included in the repo.

git clone https://github.com/defnetuncer98/triangulateMe.git
cd triangulateMe

# Serve with any static file server, e.g.:
python3 -m http.server 8000

Then open http://localhost:8000 in your browser.

Project Structure

triangulateMe/
β”œβ”€β”€ index.html                  # Single-page app entry point
└── resources/
    β”œβ”€β”€ css/style.css
    β”œβ”€β”€ fonts/                  # Roboto (for in-scene 3D text labels)
    β”œβ”€β”€ images/                 # Custom cursor & UI gifs
    └── js/
        β”œβ”€β”€ app.js              # Page routing & global input handling
        β”œβ”€β”€ init.js             # Three.js scene setup
        β”œβ”€β”€ home.js             # Landing page
        β”œβ”€β”€ triangulate.js      # Module 1: triangulation by graph coloring
        β”œβ”€β”€ motion-planning.js  # Module 2: fat triangulation + Dijkstra
        β”œβ”€β”€ 2d-shadow.js        # Module 3: light/shadow computation
        β”œβ”€β”€ delaunay.js         # Delaunay triangulation
        β”œβ”€β”€ dijkstra.js         # Shortest path
        β”œβ”€β”€ polygon.js          # Polygon model (orientation, in-cone, intersection tests)
        β”œβ”€β”€ point.js / line.js  # Geometry primitives
        └── common-*.js         # Shared helpers (math, Three.js utilities)

Built With

  • Three.js β€” rendering, scene management, and 3D text
  • Vanilla JavaScript β€” all geometry algorithms implemented from scratch (except the Delaunay routine)
  • Font Awesome β€” icons

Author

Defne TunΓ§er β€” @defnetuncer98

Created for the Computational Geometry coursework, Computer Graphics MSc @ Hacettepe University.

About

triangulateMe is a polygon triangulation application made with ThreeJS πŸ“βœπŸ‘½

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages