Skip to content

revanaii/Computational-geometry

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Computational Geometry Unity Library

This library consists of two folders. The idea is that one is for testing purposes and the other folder is the folder you drag into your project.

Make sure all input coordinates are normalized to range 0-1 to avoid floating point precision issues! Normalizing methods exists in HelpMethods. This is not always needed but if you notice that an algorithm doesn't work, try to normalize the input coordinates.

Some of these algorithms are available in tutorial form here: https://www.habrador.com/tutorials/math/

Finished

1. Intersection

1.1 2d-space

Point-triangle

Intersection point-triangle

Point-polygon. Suffers from floating point precision issues

Intersection point-polygon

Triangle-triangle

Intersection triangle-triangle

AABB-AABB

Intersection point-triangle

Line-line

Intersection line-line

Ray-plane

Intersection ray-plane

Line-plane

Intersection line-plane

Plane-plane

Intersection plane-plane

Point-circle

Intersection point-circle

2. Generate mesh

Grid mesh

Mesh grid

Mesh shapes: Arrow, circles, lines

Mesh shapes

3. Convex Hull

*Jarvis March. Is also known as "Gift wrapping"

Convex hull jarvis march

4. Triangulation

Triangulate convex polygon. Is working with colinear points

Triangulation convex polygon

Triangulate points with "visible edge" algorithm. Is maybe working with colinear points

Triangulation visible edges

Triangulate points with "point-by-point" algorithm. Is working with colinear points (because Triangulate convex polygon is working with colinear points)

Triangulation point-by-point

4.1 Delaunay triangulation

"point-by-point" method

Triangulation Delaunay point-by-point

"flip edges" method

Triangulation Delaunay flip edges

Constrained triangulation

Triangulation Delaunay constrained

5. Voronoi diagram

From a Delaunay triangulation

Voronoi from delaunay

6. Polygon clipping

Greiner-Hormann method

Polygon clipping greiner

Sutherland-Hodgman method

Polygon clipping sutherland

7. Other

Is a triangle oriented clockwise?

Triangle orientation

Is a point left, on, or right of vector?

Point vector orientation

Is a point left, on, or right of a plane? Which is the same as the distance to the plane.

Point plane orientation

Is a quadrilateral convex?

Quadrilateral convex or concave

Is a point between two other points on the same line?

Is point between points on line segment

Closest point on a line-segment?

Closest point on line segment

TODO

Algorithms to implement

  • Dynamic constrained delaunay triangulation
  • Convex hull: Quickhull from the Valve paper
  • Convex hull: Graham scan
  • Marching cubes
  • Cut 3d mesh with plane
  • Metaballs
  • Voronoi with Fortune's algorithm
  • Voronoi point-by-point
  • Triangulation concave polygon by ear clipping
  • Rectangle-rectangle with SAT
  • Triangulate with marching squares

Stuff to fix

  • Optimize Constrained Delaunay - there's a faster method to find edges that intersects with the constrained edge. I also think the method where triangles within the constrain is removed can be faster.

Socials

Follow me on Twitter for more Unity stuff: https://twitter.com/eriknordeus

About

Computational Geometry Unity library with implementations of intersection algorithms, triangulations like delaunay, voronoi diagrams, polygon clipping, etc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 100.0%