-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
2952 lines (2556 loc) · 284 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({"/Users/Romain/Documents/Programmation/ants/AntColony/example/start.js":[function(require,module,exports){
'use strict';
var _antColony = require('../index.js');
var container = document.querySelector('.colony');
var options = {
velocity: 0.001,
nbAnts: 3000,
intelligence: 0.95,
repSize: 0.05,
repSpeed: 0.002,
nbStart: 500,
nbRand: 1000
// obj par defaut
};
var antColony = _antColony(container, options);
window.addEventListener('click', function (){
// options.velocity = 0.003;
options.nbAnts = 3000;
// options.weight = 10000000;
// options.repSpeed = 0.01;
// options.repSize = 0.1;
// antColony.changeOptions(options);
antColony.changeOptions(options);
});
},{"../index.js":"/Users/Romain/Documents/Programmation/ants/AntColony/index.js"}],"/Users/Romain/Documents/Programmation/ants/AntColony/index.js":[function(require,module,exports){
'use strict';
var initRendering = require('./src/rendering.js');
var initializePoints = require('./src/initializePoints.js');
var createEdges = require('./src/createEdges.js');
// var initAnts = require('./src/initializeAnts');
module.exports = function init(containerElement, options){
var render, pointsInfos, edges, population, pointsMap;
function _init(containerElement, options){
pointsInfos = initializePoints(options.nbStart, options.nbRand);
edges = createEdges(pointsInfos.points);
// population = options.nbAnts;
// population = initAnts(containerElement, pointsInfos, options);
pointsMap = {
pointsInfos: pointsInfos,
edges: edges
// population: population
};
render = initRendering(containerElement, pointsMap, options);
}
_init(containerElement, options);
return {
togglePlayPause: function(){ render.togglePlayPause() },
changeOptions: function(opts){
render.modifyAnts(opts);
},
reset: function(opts){
render.reset();
// reset elements
_init(containerElement, opts);
}
};
};
},{"./src/createEdges.js":"/Users/Romain/Documents/Programmation/ants/AntColony/src/createEdges.js","./src/initializePoints.js":"/Users/Romain/Documents/Programmation/ants/AntColony/src/initializePoints.js","./src/rendering.js":"/Users/Romain/Documents/Programmation/ants/AntColony/src/rendering.js"}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/ich.js":[function(require,module,exports){
"use strict"
//High level idea:
// 1. Use Clarkson's incremental construction to find convex hull
// 2. Point location in triangulation by jump and walk
module.exports = incrementalConvexHull
var orient = require("robust-orientation")
var compareCell = require("simplicial-complex").compareCells
function compareInt(a, b) {
return a - b
}
function Simplex(vertices, adjacent, boundary) {
this.vertices = vertices
this.adjacent = adjacent
this.boundary = boundary
this.lastVisited = -1
}
Simplex.prototype.flip = function() {
var t = this.vertices[0]
this.vertices[0] = this.vertices[1]
this.vertices[1] = t
var u = this.adjacent[0]
this.adjacent[0] = this.adjacent[1]
this.adjacent[1] = u
}
function GlueFacet(vertices, cell, index) {
this.vertices = vertices
this.cell = cell
this.index = index
}
function compareGlue(a, b) {
return compareCell(a.vertices, b.vertices)
}
function bakeOrient(d) {
var code = ["function orient(){var tuple=this.tuple;return test("]
for(var i=0; i<=d; ++i) {
if(i > 0) {
code.push(",")
}
code.push("tuple[", i, "]")
}
code.push(")}return orient")
var proc = new Function("test", code.join(""))
var test = orient[d+1]
if(!test) {
test = orient
}
return proc(test)
}
var BAKED = []
function Triangulation(dimension, vertices, simplices) {
this.dimension = dimension
this.vertices = vertices
this.simplices = simplices
this.interior = simplices.filter(function(c) {
return !c.boundary
})
this.tuple = new Array(dimension+1)
for(var i=0; i<=dimension; ++i) {
this.tuple[i] = this.vertices[i]
}
var o = BAKED[dimension]
if(!o) {
o = BAKED[dimension] = bakeOrient(dimension)
}
this.orient = o
}
var proto = Triangulation.prototype
//Degenerate situation where we are on boundary, but coplanar to face
proto.handleBoundaryDegeneracy = function(cell, point) {
var d = this.dimension
var n = this.vertices.length - 1
var tuple = this.tuple
var verts = this.vertices
//Dumb solution: Just do dfs from boundary cell until we find any peak, or terminate
var toVisit = [ cell ]
cell.lastVisited = -n
while(toVisit.length > 0) {
cell = toVisit.pop()
var cellVerts = cell.vertices
var cellAdj = cell.adjacent
for(var i=0; i<=d; ++i) {
var neighbor = cellAdj[i]
if(!neighbor.boundary || neighbor.lastVisited <= -n) {
continue
}
var nv = neighbor.vertices
for(var j=0; j<=d; ++j) {
var vv = nv[j]
if(vv < 0) {
tuple[j] = point
} else {
tuple[j] = verts[vv]
}
}
var o = this.orient()
if(o > 0) {
return neighbor
}
neighbor.lastVisited = -n
if(o === 0) {
toVisit.push(neighbor)
}
}
}
return null
}
proto.walk = function(point, random) {
//Alias local properties
var n = this.vertices.length - 1
var d = this.dimension
var verts = this.vertices
var tuple = this.tuple
//Compute initial jump cell
var initIndex = random ? (this.interior.length * Math.random())|0 : (this.interior.length-1)
var cell = this.interior[ initIndex ]
//Start walking
outerLoop:
while(!cell.boundary) {
var cellVerts = cell.vertices
var cellAdj = cell.adjacent
for(var i=0; i<=d; ++i) {
tuple[i] = verts[cellVerts[i]]
}
cell.lastVisited = n
//Find farthest adjacent cell
for(var i=0; i<=d; ++i) {
var neighbor = cellAdj[i]
if(neighbor.lastVisited >= n) {
continue
}
var prev = tuple[i]
tuple[i] = point
var o = this.orient()
tuple[i] = prev
if(o < 0) {
cell = neighbor
continue outerLoop
} else {
if(!neighbor.boundary) {
neighbor.lastVisited = n
} else {
neighbor.lastVisited = -n
}
}
}
return
}
return cell
}
proto.addPeaks = function(point, cell) {
var n = this.vertices.length - 1
var d = this.dimension
var verts = this.vertices
var tuple = this.tuple
var interior = this.interior
var simplices = this.simplices
//Walking finished at boundary, time to add peaks
var tovisit = [ cell ]
//Stretch initial boundary cell into a peak
cell.lastVisited = n
cell.vertices[cell.vertices.indexOf(-1)] = n
cell.boundary = false
interior.push(cell)
//Record a list of all new boundaries created by added peaks so we can glue them together when we are all done
var glueFacets = []
//Do a traversal of the boundary walking outward from starting peak
while(tovisit.length > 0) {
//Pop off peak and walk over adjacent cells
var cell = tovisit.pop()
var cellVerts = cell.vertices
var cellAdj = cell.adjacent
var indexOfN = cellVerts.indexOf(n)
if(indexOfN < 0) {
continue
}
for(var i=0; i<=d; ++i) {
if(i === indexOfN) {
continue
}
//For each boundary neighbor of the cell
var neighbor = cellAdj[i]
if(!neighbor.boundary || neighbor.lastVisited >= n) {
continue
}
var nv = neighbor.vertices
//Test if neighbor is a peak
if(neighbor.lastVisited !== -n) {
//Compute orientation of p relative to each boundary peak
var indexOfNeg1 = 0
for(var j=0; j<=d; ++j) {
if(nv[j] < 0) {
indexOfNeg1 = j
tuple[j] = point
} else {
tuple[j] = verts[nv[j]]
}
}
var o = this.orient()
//Test if neighbor cell is also a peak
if(o > 0) {
nv[indexOfNeg1] = n
neighbor.boundary = false
interior.push(neighbor)
tovisit.push(neighbor)
neighbor.lastVisited = n
continue
} else {
neighbor.lastVisited = -n
}
}
var na = neighbor.adjacent
//Otherwise, replace neighbor with new face
var vverts = cellVerts.slice()
var vadj = cellAdj.slice()
var ncell = new Simplex(vverts, vadj, true)
simplices.push(ncell)
//Connect to neighbor
var opposite = na.indexOf(cell)
if(opposite < 0) {
continue
}
na[opposite] = ncell
vadj[indexOfN] = neighbor
//Connect to cell
vverts[i] = -1
vadj[i] = cell
cellAdj[i] = ncell
//Flip facet
ncell.flip()
//Add to glue list
for(var j=0; j<=d; ++j) {
var uu = vverts[j]
if(uu < 0 || uu === n) {
continue
}
var nface = new Array(d-1)
var nptr = 0
for(var k=0; k<=d; ++k) {
var vv = vverts[k]
if(vv < 0 || k === j) {
continue
}
nface[nptr++] = vv
}
glueFacets.push(new GlueFacet(nface, ncell, j))
}
}
}
//Glue boundary facets together
glueFacets.sort(compareGlue)
for(var i=0; i+1<glueFacets.length; i+=2) {
var a = glueFacets[i]
var b = glueFacets[i+1]
var ai = a.index
var bi = b.index
if(ai < 0 || bi < 0) {
continue
}
a.cell.adjacent[a.index] = b.cell
b.cell.adjacent[b.index] = a.cell
}
}
proto.insert = function(point, random) {
//Add point
var verts = this.vertices
verts.push(point)
var cell = this.walk(point, random)
if(!cell) {
return
}
//Alias local properties
var d = this.dimension
var tuple = this.tuple
//Degenerate case: If point is coplanar to cell, then walk until we find a non-degenerate boundary
for(var i=0; i<=d; ++i) {
var vv = cell.vertices[i]
if(vv < 0) {
tuple[i] = point
} else {
tuple[i] = verts[vv]
}
}
var o = this.orient(tuple)
if(o < 0) {
return
} else if(o === 0) {
cell = this.handleBoundaryDegeneracy(cell, point)
if(!cell) {
return
}
}
//Add peaks
this.addPeaks(point, cell)
}
//Extract all boundary cells
proto.boundary = function() {
var d = this.dimension
var boundary = []
var cells = this.simplices
var nc = cells.length
for(var i=0; i<nc; ++i) {
var c = cells[i]
if(c.boundary) {
var bcell = new Array(d)
var cv = c.vertices
var ptr = 0
var parity = 0
for(var j=0; j<=d; ++j) {
if(cv[j] >= 0) {
bcell[ptr++] = cv[j]
} else {
parity = j&1
}
}
if(parity === (d&1)) {
var t = bcell[0]
bcell[0] = bcell[1]
bcell[1] = t
}
boundary.push(bcell)
}
}
return boundary
}
function incrementalConvexHull(points, randomSearch) {
var n = points.length
if(n === 0) {
throw new Error("Must have at least d+1 points")
}
var d = points[0].length
if(n <= d) {
throw new Error("Must input at least d+1 points")
}
//FIXME: This could be degenerate, but need to select d+1 non-coplanar points to bootstrap process
var initialSimplex = points.slice(0, d+1)
//Make sure initial simplex is positively oriented
var o = orient.apply(void 0, initialSimplex)
if(o === 0) {
throw new Error("Input not in general position")
}
var initialCoords = new Array(d+1)
for(var i=0; i<=d; ++i) {
initialCoords[i] = i
}
if(o < 0) {
initialCoords[0] = 1
initialCoords[1] = 0
}
//Create initial topological index, glue pointers together (kind of messy)
var initialCell = new Simplex(initialCoords, new Array(d+1), false)
var boundary = initialCell.adjacent
var list = new Array(d+2)
for(var i=0; i<=d; ++i) {
var verts = initialCoords.slice()
for(var j=0; j<=d; ++j) {
if(j === i) {
verts[j] = -1
}
}
var t = verts[0]
verts[0] = verts[1]
verts[1] = t
var cell = new Simplex(verts, new Array(d+1), true)
boundary[i] = cell
list[i] = cell
}
list[d+1] = initialCell
for(var i=0; i<=d; ++i) {
var verts = boundary[i].vertices
var adj = boundary[i].adjacent
for(var j=0; j<=d; ++j) {
var v = verts[j]
if(v < 0) {
adj[j] = initialCell
continue
}
for(var k=0; k<=d; ++k) {
if(boundary[k].vertices.indexOf(v) < 0) {
adj[j] = boundary[k]
}
}
}
}
//Initialize triangles
var triangles = new Triangulation(d, initialSimplex, list)
//Insert remaining points
var useRandom = !!randomSearch
for(var i=d+1; i<n; ++i) {
triangles.insert(points[i], useRandom)
}
//Extract boundary cells
return triangles.boundary()
}
},{"robust-orientation":"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/orientation.js","simplicial-complex":"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/simplicial-complex/topology.js"}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/robust-scale/node_modules/two-sum/two-sum.js":[function(require,module,exports){
"use strict"
module.exports = fastTwoSum
function fastTwoSum(a, b, result) {
var x = a + b
var bv = x - a
var av = x - bv
var br = b - bv
var ar = a - av
if(result) {
result[0] = ar + br
result[1] = x
return result
}
return [ar+br, x]
}
},{}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/robust-scale/robust-scale.js":[function(require,module,exports){
"use strict"
var twoProduct = require("two-product")
var twoSum = require("two-sum")
module.exports = scaleLinearExpansion
function scaleLinearExpansion(e, scale) {
var n = e.length
if(n === 1) {
var ts = twoProduct(e[0], scale)
if(ts[0]) {
return ts
}
return [ ts[1] ]
}
var g = new Array(2 * n)
var q = [0.1, 0.1]
var t = [0.1, 0.1]
var count = 0
twoProduct(e[0], scale, q)
if(q[0]) {
g[count++] = q[0]
}
for(var i=1; i<n; ++i) {
twoProduct(e[i], scale, t)
var pq = q[1]
twoSum(pq, t[0], q)
if(q[0]) {
g[count++] = q[0]
}
var a = t[1]
var b = q[1]
var x = a + b
var bv = x - a
var y = b - bv
q[1] = x
if(y) {
g[count++] = y
}
}
if(q[1]) {
g[count++] = q[1]
}
if(count === 0) {
g[count++] = 0.0
}
g.length = count
return g
}
},{"two-product":"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/two-product/two-product.js","two-sum":"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/robust-scale/node_modules/two-sum/two-sum.js"}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/robust-subtract/robust-diff.js":[function(require,module,exports){
"use strict"
module.exports = robustSubtract
//Easy case: Add two scalars
function scalarScalar(a, b) {
var x = a + b
var bv = x - a
var av = x - bv
var br = b - bv
var ar = a - av
var y = ar + br
if(y) {
return [y, x]
}
return [x]
}
function robustSubtract(e, f) {
var ne = e.length|0
var nf = f.length|0
if(ne === 1 && nf === 1) {
return scalarScalar(e[0], -f[0])
}
var n = ne + nf
var g = new Array(n)
var count = 0
var eptr = 0
var fptr = 0
var abs = Math.abs
var ei = e[eptr]
var ea = abs(ei)
var fi = -f[fptr]
var fa = abs(fi)
var a, b
if(ea < fa) {
b = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
b = fi
fptr += 1
if(fptr < nf) {
fi = -f[fptr]
fa = abs(fi)
}
}
if((eptr < ne && ea < fa) || (fptr >= nf)) {
a = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
a = fi
fptr += 1
if(fptr < nf) {
fi = -f[fptr]
fa = abs(fi)
}
}
var x = a + b
var bv = x - a
var y = b - bv
var q0 = y
var q1 = x
var _x, _bv, _av, _br, _ar
while(eptr < ne && fptr < nf) {
if(ea < fa) {
a = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
a = fi
fptr += 1
if(fptr < nf) {
fi = -f[fptr]
fa = abs(fi)
}
}
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
}
while(eptr < ne) {
a = ei
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
eptr += 1
if(eptr < ne) {
ei = e[eptr]
}
}
while(fptr < nf) {
a = fi
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
fptr += 1
if(fptr < nf) {
fi = -f[fptr]
}
}
if(q0) {
g[count++] = q0
}
if(q1) {
g[count++] = q1
}
if(!count) {
g[count++] = 0.0
}
g.length = count
return g
}
},{}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/robust-sum/robust-sum.js":[function(require,module,exports){
"use strict"
module.exports = linearExpansionSum
//Easy case: Add two scalars
function scalarScalar(a, b) {
var x = a + b
var bv = x - a
var av = x - bv
var br = b - bv
var ar = a - av
var y = ar + br
if(y) {
return [y, x]
}
return [x]
}
function linearExpansionSum(e, f) {
var ne = e.length|0
var nf = f.length|0
if(ne === 1 && nf === 1) {
return scalarScalar(e[0], f[0])
}
var n = ne + nf
var g = new Array(n)
var count = 0
var eptr = 0
var fptr = 0
var abs = Math.abs
var ei = e[eptr]
var ea = abs(ei)
var fi = f[fptr]
var fa = abs(fi)
var a, b
if(ea < fa) {
b = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
b = fi
fptr += 1
if(fptr < nf) {
fi = f[fptr]
fa = abs(fi)
}
}
if((eptr < ne && ea < fa) || (fptr >= nf)) {
a = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
a = fi
fptr += 1
if(fptr < nf) {
fi = f[fptr]
fa = abs(fi)
}
}
var x = a + b
var bv = x - a
var y = b - bv
var q0 = y
var q1 = x
var _x, _bv, _av, _br, _ar
while(eptr < ne && fptr < nf) {
if(ea < fa) {
a = ei
eptr += 1
if(eptr < ne) {
ei = e[eptr]
ea = abs(ei)
}
} else {
a = fi
fptr += 1
if(fptr < nf) {
fi = f[fptr]
fa = abs(fi)
}
}
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
}
while(eptr < ne) {
a = ei
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
eptr += 1
if(eptr < ne) {
ei = e[eptr]
}
}
while(fptr < nf) {
a = fi
b = q0
x = a + b
bv = x - a
y = b - bv
if(y) {
g[count++] = y
}
_x = q1 + x
_bv = _x - q1
_av = _x - _bv
_br = x - _bv
_ar = q1 - _av
q0 = _ar + _br
q1 = _x
fptr += 1
if(fptr < nf) {
fi = f[fptr]
}
}
if(q0) {
g[count++] = q0
}
if(q1) {
g[count++] = q1
}
if(!count) {
g[count++] = 0.0
}
g.length = count
return g
}
},{}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/node_modules/two-product/two-product.js":[function(require,module,exports){
"use strict"
module.exports = twoProduct
var SPLITTER = +(Math.pow(2, 27) + 1.0)
function twoProduct(a, b, result) {
var x = a * b
var c = SPLITTER * a
var abig = c - a
var ahi = c - abig
var alo = a - ahi
var d = SPLITTER * b
var bbig = d - b
var bhi = d - bbig
var blo = b - bhi
var err1 = x - (ahi * bhi)
var err2 = err1 - (alo * bhi)
var err3 = err2 - (ahi * blo)
var y = alo * blo - err3
if(result) {
result[0] = y
result[1] = x
return result
}
return [ y, x ]
}
},{}],"/Users/Romain/Documents/Programmation/ants/AntColony/node_modules/delaunay-triangulate/node_modules/incremental-convex-hull/node_modules/robust-orientation/orientation.js":[function(require,module,exports){
"use strict"
var twoProduct = require("two-product")
var robustSum = require("robust-sum")
var robustScale = require("robust-scale")
var robustSubtract = require("robust-subtract")
var NUM_EXPAND = 5
var EPSILON = 1.1102230246251565e-16
var ERRBOUND3 = (3.0 + 16.0 * EPSILON) * EPSILON
var ERRBOUND4 = (7.0 + 56.0 * EPSILON) * EPSILON
function cofactor(m, c) {
var result = new Array(m.length-1)
for(var i=1; i<m.length; ++i) {
var r = result[i-1] = new Array(m.length-1)
for(var j=0,k=0; j<m.length; ++j) {
if(j === c) {
continue
}
r[k++] = m[i][j]
}
}
return result
}
function matrix(n) {
var result = new Array(n)
for(var i=0; i<n; ++i) {
result[i] = new Array(n)
for(var j=0; j<n; ++j) {
result[i][j] = ["m", j, "[", (n-i-1), "]"].join("")
}
}
return result
}
function sign(n) {
if(n & 1) {
return "-"
}
return ""
}
function generateSum(expr) {
if(expr.length === 1) {
return expr[0]
} else if(expr.length === 2) {
return ["sum(", expr[0], ",", expr[1], ")"].join("")
} else {
var m = expr.length>>1
return ["sum(", generateSum(expr.slice(0, m)), ",", generateSum(expr.slice(m)), ")"].join("")
}
}
function determinant(m) {
if(m.length === 2) {
return [["sum(prod(", m[0][0], ",", m[1][1], "),prod(-", m[0][1], ",", m[1][0], "))"].join("")]
} else {
var expr = []
for(var i=0; i<m.length; ++i) {