Skip to content

Commit f91c716

Browse files
committed
Initial release
0 parents  commit f91c716

File tree

11 files changed

+2497
-0
lines changed

11 files changed

+2497
-0
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
*.bat
2+
ldoc*
3+
telescope*
4+
tsc
5+
config*
6+
test*

README.md

+106
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
Delaunay
2+
=====
3+
4+
*delaunay* is a Lua module for [delaunay triangulation](http://en.wikipedia.org/wiki/Delaunay_triangulation) of a convex polygon.
5+
6+
##Download
7+
8+
###Git
9+
10+
````
11+
git clone http://github.com/Yonaba/delaunay.git
12+
````
13+
14+
###Archive
15+
16+
* [zip](http://github.com/Yonaba/delaunay/archive/3delaunay-0.6.0.zip) | [tar.gz](http://github.com/Yonaba/30log/archive/30log-0.6.0.tar.gz) | [all](http://github.com/Yonaba/30log/tags)
17+
18+
###LuaRocks
19+
20+
````
21+
luarocks install delaunay
22+
````
23+
24+
###MoonRocks
25+
26+
````
27+
luarocks install --server=http://rocks.moonscript.org/manifests/Yonaba delaunay
28+
````
29+
30+
##Installation
31+
Copy the file [delaunay.lua](https://github.com/Yonaba/delaunay/blob/master/delaunay.lua) inside your project folder,
32+
call it with [require](http://pgl.yoyo.org/luai/i/require) function. It will return the `Delaunay` module, keeping safe the global environment.<br/>
33+
34+
##Usage
35+
36+
The module provides 3 classes: <br/>
37+
* `Point`
38+
* `Edge`
39+
* `Triangle`
40+
41+
It also provides a single function named `triangulate`. This function accepts
42+
a variable list (*vararg* `...`) of instances of class `Point`. Assuming those
43+
points are the vertices of a convex polygon, it returns a table of instances of the class `Triangle` forming a *Delaunay triangulation* of the given polygon.
44+
45+
A basic code example:
46+
```lua
47+
local Delaunay = require 'Delaunay'
48+
local Point = Delaunay.Point
49+
50+
-- Creating 10 random points
51+
local points = {}
52+
for i = 1, 10 do
53+
points[i] = Point(math.random() * 100, math.random() * 100)
54+
end
55+
56+
-- Triangulating de convex polygon made by those points
57+
local triangles = Delaunay.triangulate(unpack(points))
58+
59+
-- Printing the results
60+
for i, triangle in ipairs(triangles) do
61+
print(triangle)
62+
end
63+
````
64+
65+
See the documentation for more details.
66+
```
67+
68+
##Testing
69+
###Specification
70+
71+
This repository include unit tests. You can run them using [Telescope](https://github.com/norman/telescope) with the following command from the root foolder:
72+
73+
```
74+
lua tsc -f specs/*
75+
```
76+
77+
###Performance
78+
79+
You can run the random performance tests included with the following command from the root folder:
80+
81+
```lua
82+
lua performance/bench.lua
83+
````
84+
85+
##License
86+
This work is under [MIT-LICENSE](http://www.opensource.org/licenses/mit-license.php).<br/>
87+
Copyright (c) 2013 Roland Yonaba
88+
89+
Permission is hereby granted, free of charge, to any person obtaining a
90+
copy of this software and associated documentation files (the
91+
"Software"), to deal in the Software without restriction, including
92+
without limitation the rights to use, copy, modify, merge, publish,
93+
distribute, sublicense, and/or sell copies of the Software, and to
94+
permit persons to whom the Software is furnished to do so, subject to
95+
the following conditions:
96+
97+
The above copyright notice and this permission notice shall be included
98+
in all copies or substantial portions of the Software.
99+
100+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
101+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
102+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
103+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
104+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
105+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
106+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)