GithubHelp home page GithubHelp logo

habrador / computational-geometry Goto Github PK

View Code? Open in Web Editor NEW
1.2K 46.0 140.0 5.75 MB

Computational Geometry Unity library with implementations of intersection algorithms, triangulations like delaunay, voronoi diagrams, polygon clipping, bezier curves, ear clipping, convex hulls, mesh simplification, etc

Home Page: https://www.habrador.com/

License: MIT License

C# 91.06% ShaderLab 7.91% HLSL 1.04%
unity3d computational-geometry voronoi intersections convex-hull polygon-clipping triangulation constrained-delaunay-triangulation jarvis-march gift-wrapping

computational-geometry's Introduction

Hi!

Welcome to the #6135 most starred GitHub account in the world (Source) and the #126 most followed account in Sweden (Source)!

GitHub Repo stars

The one who's running the show is me, Erik Nordeus. I'm an imagineer (creative engineer) who's interested in the intersection between art and engineering. I design mostly Unity and Blender projects. After finishing my mandatory military service, defending King and country, I got a master's degree in Mechanical Engineering from the Royal Institute of Technology (KTH) in Stockholm, Sweden, where I also live. The rest is history...

My goal with my open source projects is that the code should by as easy as possible for you to understand, so I love to comment it! I once wrote a book about a guy called Elon Musk, and I read somewhere that authors are the best at commenting code because they know how to explain complicated topics in a simple way. Thus I hope I will fulfill my promises!

Connect With Me

Experiences

Languages: C# • Python • JavaScript • HTML • CSS • MATLAB • PHP • MySQL

Tools: Visual StudioBlenderUnityKrita

FAQ

  • Are you related to the company Nordeus? No, my surname Nordeus is a family name. If you googled Nordeus before the Nordeus company was founded you could only find people with that name in Sweden, so I'm not sure how they got the name. But they follow me on Twitter! Kinda funny that both of us are into Unity.

THANK YOU...

...everyone who has used and contributed to my open source projects!

If you use the code for something cool then you can @ me on twitter.com/eriknordeus and I promise to retweet!

computational-geometry's People

Contributors

habrador avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

computational-geometry's Issues

Do the random points for a Voronoi diagram need to be ordered?

I'm having a problem with a set of randomly generated points that don't produce Voronoi cells properly unless I order them on the X-axis from smallest to largest.

Here are the problem sites in the order they were generated:
randomSites.Add(new Vector3(2.58301f, -0.07231092f, 0f));
randomSites.Add(new Vector3(4.260807f, 1.725296f, 0f));
randomSites.Add(new Vector3(8.839731f, -3.794293f, 0f));
randomSites.Add(new Vector3(-12.11187f, -0.3448925f, 0f));
randomSites.Add(new Vector3(8.466095f, 2.583772f, 0f));
randomSites.Add(new Vector3(3.597496f, -1.383692f, 0f));
randomSites.Add(new Vector3(3.421845f, 0.8252826f, 0f));
randomSites.Add(new Vector3(-7.763506f, -1.487227f, 0f));
randomSites.Add(new Vector3(-0.6644406f, 1.276973f, 0f));
randomSites.Add(new Vector3(7.997253f, 2.485325f, 0f));
randomSites.Add(new Vector3(3.234119f, -3.716683f, 0f));
randomSites.Add(new Vector3(11.37916f, 3.904939f, 0f));
randomSites.Add(new Vector3(11.13493f, -0.3131549f, 0f));
randomSites.Add(new Vector3(6.510168f, 7.292708f, 0f));
randomSites.Add(new Vector3(-2.473285f, 5.793113f, 0f));
randomSites.Add(new Vector3(-8.900781f, -1.143157f, 0f));

If I reorder these, the Voronoi diagrams are generated correctly:
randomSites.Add(new Vector3(-12.11187f, -0.3448925f, 0f));
randomSites.Add(new Vector3(-8.900781f, -1.143157f, 0f));
randomSites.Add(new Vector3(-7.763506f, -1.487227f, 0f));
randomSites.Add(new Vector3(-2.473285f, 5.793113f, 0f));
randomSites.Add(new Vector3(-0.6644406f, 1.276973f, 0f));
randomSites.Add(new Vector3(2.58301f, -0.07231092f, 0f));
randomSites.Add(new Vector3(3.234119f, -3.716683f, 0f));
randomSites.Add(new Vector3(3.421845f, 0.8252826f, 0f));
randomSites.Add(new Vector3(3.597496f, -1.383692f, 0f));
randomSites.Add(new Vector3(4.260807f, 1.725296f, 0f));
randomSites.Add(new Vector3(6.510168f, 7.292708f, 0f));
randomSites.Add(new Vector3(7.997253f, 2.485325f, 0f));
randomSites.Add(new Vector3(8.466095f, 2.583772f, 0f));
randomSites.Add(new Vector3(8.839731f, -3.794293f, 0f));
randomSites.Add(new Vector3(11.13493f, -0.3131549f, 0f));
randomSites.Add(new Vector3(11.37916f, 3.904939f, 0f));

I've uploaded a picture of the Voronoi gizmos before after sorting here (look in Orion's belt):
https://imgur.com/a/2MpFrIu

Fixes for Greiner Hormann clipping

Hey, thanks for making this very useful.

I did have some issues with the clipping Greiner Hormann clipping which I think fixed or made less broken.
If you have to time to look over that I can setup a pull request?

Using it to preprocess holes before triangulation, eg:

image

I can add bits for that too if you want.

-Jim

Constrained delaunay failing at PointTriangulationIntersection.TriangulationWalk

Hello. I'm trying to create a constrained delaunay graph using _Delaunay.ConstrainedBySloan and I'm getting the below error:

NullReferenceException: Object reference not set to an instance of an object
Habrador_Computational_Geometry.PointTriangulationIntersection.TriangulationWalk

_Habrador Computational Geometry Library/1. Intersection/PointTriangulationIntersection.cs:149

My parameters are in the right clockwise (or anti clockwise) direction so I'm not sure what I'm missing.

Is there anything you can suggest that might help? I couldn't see a functioning example for constrained delaunay other than the ear clipping one, and that seems to fail with more than one hole in a square hull. Thanks!

JarvisMarshArlorithm2D: must test for points starvation

Hello Erik. First, thanks for your great job . I mainly used your jarvisMarhsallAlgorithm2D. I wanted to raise your attention upon the following trap in which I have fallen quite often (I deal with hundrerds of various 2d Shapes points and need to build convex hull of each shape).
Even if I did not spent much time to understand precisely the algorithm, I had to change line 54 of JarvisMarchAlgorithm2D.cs like this:

 while (true && points.Count > 0)

Since all points may habe been removed by code at line 125
and that and radom access in points in made line 61

This has been enough for my needs but It might need your insight

Anyway, thanks again. This has been really usefull for me.

Emmanuel

Consider making this a Unity Package?

Would you consider compiling this into a git package so that we can add it via the package manager? this means we would be able to get updates if we required and wouldn't need to manually import

See Howto

Implement Tetrahedralize 3D points

Similar to LightProbes.Tetrahedralize(), except it's exposed. It should output an array of Tetrahedron objects. It should also be memory efficient (use indices instead duplicate data and stuff) and have rather good realtime performance.

Could be useful for global illumination techniques.

Just an idea, might try implementing this myself, but I am not really good with geometry...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.