-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRamaswamy_HW2.nb
2035 lines (2011 loc) · 91.7 KB
/
Ramaswamy_HW2.nb
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
(* Content-type: application/vnd.wolfram.mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 11.3' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 158, 7]
NotebookDataLength[ 91712, 2027]
NotebookOptionsPosition[ 89998, 1992]
NotebookOutlinePosition[ 90363, 2008]
CellTagsIndexPosition[ 90320, 2005]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell["\<\
Homework-2 :Discrete Geometry
\
\>", "Title",
CellChangeTimes->{{3.746997502679221*^9,
3.7469975200491743`*^9}},ExpressionUUID->"4b370792-d243-4097-bb1e-\
9a3cd9789aaa"],
Cell[CellGroupData[{
Cell["\<\
Part 1: Barycentric Coordinates
\
\>", "Chapter",
CellChangeTimes->{{3.7469975453311815`*^9,
3.7469975603030186`*^9}},ExpressionUUID->"5aa7b981-d2ec-45da-8141-\
1737ba0a6862"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
"Function", " ", "to", " ", "calculate", " ", "the", " ", "neighbour", " ",
"triangles", " ", "of", " ", "set", " ", "of", " ", "triangles"}], " ",
"*)"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{
RowBox[{"NeighbourFunction", "[",
RowBox[{"pts_", ",", "tris_", ",", "noTris_"}], "]"}], ":=",
"\[IndentingNewLine]",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a", ",", "b", ",", "c", ",", "a1", ",", "b1", ",", "c1", ",",
RowBox[{"numtris", "=", "noTris"}], ",",
RowBox[{"result", "=",
RowBox[{"{", "}"}]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"result", "=",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"{", "}"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "1", ",", "numtris"}], "}"}]}], "]"}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"For", "[",
RowBox[{
RowBox[{"t1", "=", "1"}], ",",
RowBox[{"t1", "\[LessEqual]", "numtris"}], ",",
RowBox[{"t1", "=",
RowBox[{"t1", "+", "1"}]}], ",", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"a", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t1", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"b", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t1", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"c", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t1", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"For", "[",
RowBox[{
RowBox[{"t2", "=", "1"}], ",",
RowBox[{"t2", "\[LessEqual]", "numtris"}], ",",
RowBox[{"t2", "=",
RowBox[{"t2", "+", "1"}]}], ",", "\[IndentingNewLine]",
RowBox[{
RowBox[{"If", "[",
RowBox[{
RowBox[{"t1", "\[NotEqual]", "t2"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"a1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"b1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t2", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"c1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"t2", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"Length", "[",
RowBox[{"Intersection", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a", ",", "b", ",", "c"}], "}"}], ",",
RowBox[{"{",
RowBox[{"a1", ",", "b1", ",", "c1"}], "}"}]}], "]"}],
"]"}], "\[Equal]", "2"}], ",",
RowBox[{"PrependTo", "[",
RowBox[{
RowBox[{"result", "[",
RowBox[{"[", "t1", "]"}], "]"}], ",", "t2"}], "]"}]}],
"]"}], ";"}]}], "\[IndentingNewLine]",
"\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]",
"]"}]}]}], "]"}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]", "result"}]}], "]"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input",
CellChangeTimes->{{3.7470049953768773`*^9, 3.747005055237352*^9}, {
3.7470051765349607`*^9, 3.747005227675456*^9}, {3.7470053367110405`*^9,
3.747005397308546*^9}, {3.747015245933696*^9, 3.747015250515238*^9}, {
3.7470152911176157`*^9, 3.7470153030098033`*^9}, 3.7470153343700833`*^9, {
3.747022007364908*^9, 3.7470220364890685`*^9}, 3.7470223883941584`*^9, {
3.747024421924423*^9, 3.747024475290842*^9}, {3.747024945674049*^9,
3.7470249736780434`*^9}, 3.747025040334417*^9, {3.7470251014734917`*^9,
3.747025284188378*^9}, {3.747025332051429*^9, 3.7470253957386217`*^9},
3.748119790273484*^9, {3.748119944241712*^9, 3.7481199574278708`*^9}, {
3.7481213455580573`*^9, 3.7481213568691397`*^9}, 3.748121404273054*^9, {
3.7481219626158185`*^9, 3.7481220158532076`*^9}, {3.748122065514462*^9,
3.74812210152738*^9}, {3.748122235316444*^9, 3.7481222699373255`*^9}, {
3.7481223870273542`*^9, 3.748122494022154*^9}, {3.748122529907075*^9,
3.7481225751802635`*^9}, {3.748122638069848*^9, 3.7481226700987024`*^9}, {
3.7481227740568967`*^9, 3.748122776742297*^9}, {3.7481229651942015`*^9,
3.7481229665108376`*^9}, {3.748124093567193*^9, 3.748124172194854*^9}, {
3.7481243912551737`*^9, 3.7481244010848083`*^9}, {3.748124453210476*^9,
3.7481245251944284`*^9}, 3.74812461814858*^9, {3.7481246689596033`*^9,
3.7481247527401896`*^9}, {3.7481252917116632`*^9,
3.7481253614643173`*^9}, {3.748125418650493*^9, 3.7481254261171837`*^9}, {
3.7481255068795567`*^9, 3.748125588736292*^9}, {3.7481258413712664`*^9,
3.7481258912904577`*^9}, 3.748125923213194*^9, {3.748126042897382*^9,
3.7481260472086706`*^9}, {3.7481260865871916`*^9,
3.7481261087699947`*^9}, {3.748126155274047*^9, 3.7481261977921705`*^9}, {
3.7481263144267592`*^9, 3.7481263170608673`*^9}, {3.7481264232738423`*^9,
3.7481264470207443`*^9}, {3.7481269067559423`*^9,
3.7481269991103115`*^9}, {3.748127038031306*^9, 3.7481270450554905`*^9}, {
3.7481271161915436`*^9, 3.7481272103491306`*^9}, 3.748127364923375*^9, {
3.7481274531335287`*^9, 3.748127454961747*^9}, {3.7481275623105526`*^9,
3.748127565982591*^9}, {3.7481284489431334`*^9, 3.748128451049096*^9}, {
3.748128519624877*^9, 3.74812854477343*^9}, {3.7481285998377075`*^9,
3.748128610234397*^9}, 3.748128664038216*^9, {3.7481287163101482`*^9,
3.748128735868167*^9}, {3.7481288223403053`*^9, 3.7481288539904013`*^9}, {
3.7481317289870024`*^9, 3.7481318268802648`*^9}, {3.748139024827222*^9,
3.7481390299856377`*^9}, {3.748139062764346*^9, 3.74813908279464*^9}, {
3.7482081047342196`*^9, 3.7482081056838493`*^9}, {3.748208229329247*^9,
3.7482082660037737`*^9}, {3.74820830890797*^9, 3.7482083236209393`*^9}, {
3.748208397517381*^9, 3.7482084903603396`*^9}, {3.748208719170594*^9,
3.7482087845237885`*^9}, {3.7482088857363477`*^9,
3.7482089110308733`*^9}, {3.7482089454636*^9, 3.748208984226387*^9}, {
3.7482090157412357`*^9, 3.7482090235534987`*^9}, {3.7482090573894553`*^9,
3.748209062023857*^9}, {3.7482090940404167`*^9, 3.7482091222720613`*^9}, {
3.7482092004803605`*^9, 3.7482092031246233`*^9}, {3.7482092751328835`*^9,
3.7482093716789227`*^9}, 3.7482094209061327`*^9, {3.7482094551798296`*^9,
3.748209466948549*^9}, {3.7482095641669044`*^9, 3.748209577600169*^9}, {
3.748209609451047*^9, 3.7482096524515543`*^9}, {3.748209697652813*^9,
3.748209701045143*^9}, {3.74820973147821*^9, 3.748209842245578*^9}, {
3.748209877044039*^9, 3.748209892994272*^9}, {3.7482099274514446`*^9,
3.748209983183875*^9}, {3.7482100216478405`*^9, 3.748210029946803*^9}, {
3.7482100644501743`*^9, 3.7482101429491587`*^9}, {3.748210250695317*^9,
3.7482102512901635`*^9}, {3.7482103404915*^9, 3.7482103894496746`*^9}, {
3.7482104545852375`*^9, 3.7482105117933464`*^9}, {3.7482105731021943`*^9,
3.748210607900131*^9}, {3.74821083271535*^9, 3.7482108455954485`*^9}, {
3.748210907488566*^9, 3.7482109691177826`*^9}, {3.748211404952052*^9,
3.7482115063517504`*^9}, {3.7482115509984365`*^9, 3.748211558194516*^9},
3.748211591307559*^9, {3.7482116820454397`*^9, 3.7482117804816446`*^9}, {
3.748211823678219*^9, 3.7482118374622955`*^9}, {3.748211868069646*^9,
3.7482118767326207`*^9}, {3.748211922196831*^9, 3.748211928837549*^9}, {
3.748211974135204*^9, 3.7482121244923034`*^9}, {3.748212179288335*^9,
3.7482122085595074`*^9}, {3.748264101293011*^9, 3.7482641129505577`*^9}, {
3.7482641561960807`*^9, 3.7482641612069826`*^9}, {3.7482642541162157`*^9,
3.748264254952422*^9}, {3.7482644235131454`*^9, 3.7482644501434803`*^9}, {
3.748306189750992*^9, 3.7483063326934285`*^9}, {3.7483063727048235`*^9,
3.7483063778512316`*^9}},
CellLabel->"In[1]:=",ExpressionUUID->"383b79bd-8ca3-4b26-a5c4-4a7f2920a303"],
Cell[BoxData[
RowBox[{" ",
RowBox[{
RowBox[{
RowBox[{"numpts", "=", "5"}], ";"}], "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{"Create", " ", "a", " ", "random", " ", "point", " ", "set"}],
"*)"}], "\[IndentingNewLine]", " ",
RowBox[{
RowBox[{"pts", "=",
RowBox[{"RandomReal", "[",
RowBox[{
RowBox[{"{",
RowBox[{"0", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"numpts", ",", "2"}], "}"}]}], "]"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{
RowBox[{"dmesh", " ", "=", " ",
RowBox[{"DelaunayMesh", "[", "pts", "]"}]}], ";"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{"tris", " ", "=", " ",
RowBox[{"MeshCells", "[",
RowBox[{"dmesh", ",", "2"}], "]"}]}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"numtris", " ", "=", " ",
RowBox[{"Length", "[", "tris", "]"}]}], ";"}], "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"Print", "[",
RowBox[{"\"\<Number of triangles numtris = \>\"", ",", "numtris"}],
"]"}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"Do", "[", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Print", "[",
RowBox[{
"\"\<Tri \>\"", ",", "i", ",", "\[IndentingNewLine]", "\"\< v1=\>\"",
",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], "]"}],
",", "\[IndentingNewLine]", "\"\< v2=\>\"", ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "2"}], "]"}], "]"}], "]"}], "]"}],
",", "\[IndentingNewLine]", "\"\< v3 = \>\"", ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "3"}], "]"}], "]"}], "]"}], "]"}]}],
"]"}], ",", "\[IndentingNewLine]",
RowBox[{"{",
RowBox[{"i", ",", "1", ",", "numtris"}], "}"}]}],
"\[IndentingNewLine]", "]"}], ";"}], "\[IndentingNewLine]",
"\[IndentingNewLine]"}]}]], "Input",
CellChangeTimes->{{3.747001607306515*^9, 3.7470017209937925`*^9}, {
3.74700188981858*^9, 3.7470019137964582`*^9}, 3.7470034193982506`*^9, {
3.747003457252366*^9, 3.747003516159836*^9}, {3.7470035882519827`*^9,
3.7470036366740685`*^9}, {3.7470036715018044`*^9,
3.7470036912374067`*^9}, {3.7470037324494667`*^9, 3.747003819596571*^9}, {
3.747004169311695*^9, 3.7470043113994465`*^9}, {3.747004355334277*^9,
3.747004417136876*^9}, {3.7470044657890234`*^9, 3.747004602217944*^9}, {
3.7470048307744455`*^9, 3.7470049629715176`*^9}, {3.7470052524182024`*^9,
3.747005327139989*^9}, {3.748119071305064*^9, 3.7481191860416565`*^9},
3.748120258793725*^9, {3.748120395085223*^9, 3.7481204032735343`*^9}, {
3.748120470576083*^9, 3.748120538995674*^9}, {3.7481212661488867`*^9,
3.748121322716459*^9}, {3.7481213651185093`*^9, 3.7481214120849147`*^9}, {
3.7481220253774323`*^9, 3.748122063622406*^9}, {3.748122805805645*^9,
3.74812281527569*^9}, {3.7481228936898146`*^9, 3.748122950091679*^9}, {
3.74812417602054*^9, 3.748124182678213*^9}, 3.7481274951548133`*^9, {
3.748313695815939*^9, 3.748313722114129*^9}, {3.7483154642911415`*^9,
3.7483154711850915`*^9}},ExpressionUUID->"3f2b1141-2c1e-46b4-a4dd-\
b4557e045414"],
Cell[BoxData[
RowBox[{
RowBox[{"(*", " ",
RowBox[{
"Get", " ", "the", " ", "neighbours", " ", "of", " ", "the", " ",
"triangles"}], " ", "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"result", "=",
RowBox[{"NeighbourFunction", "[",
RowBox[{"pts", ",", "tris", ",", "numtris"}], "]"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Print", "[", "result", "]"}], ";"}]}]}]], "Input",
CellChangeTimes->{{3.7470049953768773`*^9, 3.747005055237352*^9}, {
3.7470051765349607`*^9, 3.747005227675456*^9}, {3.7470053367110405`*^9,
3.747005397308546*^9}, {3.747015245933696*^9, 3.747015250515238*^9}, {
3.7470152911176157`*^9, 3.7470153030098033`*^9}, 3.7470153343700833`*^9, {
3.747022007364908*^9, 3.7470220364890685`*^9}, 3.7470223883941584`*^9, {
3.747024421924423*^9, 3.747024475290842*^9}, {3.747024945674049*^9,
3.7470249736780434`*^9}, 3.747025040334417*^9, {3.7470251014734917`*^9,
3.747025284188378*^9}, {3.747025332051429*^9, 3.7470253957386217`*^9},
3.748119790273484*^9, {3.748119944241712*^9, 3.7481199574278708`*^9}, {
3.748122828727791*^9, 3.74812287402159*^9}, {3.748124185081509*^9,
3.7481242149897013`*^9}, {3.748124410155465*^9, 3.7481244111755886`*^9}, {
3.7481245463174105`*^9, 3.748124605353717*^9}, {3.7481273416618557`*^9,
3.7481273567578816`*^9}, {3.7481274803682556`*^9, 3.748127512281708*^9}, {
3.7481275500706525`*^9, 3.748127712078357*^9}, {3.7481278341194882`*^9,
3.748127851170933*^9}, {3.7481278936117907`*^9, 3.7481279269318466`*^9}, {
3.7481281876164637`*^9, 3.7481282449852376`*^9}, {3.74812828398666*^9,
3.748128432170235*^9}, {3.748128463303444*^9, 3.748128473439048*^9}, {
3.748128905984063*^9, 3.7481292297839303`*^9}, {3.7481292667695866`*^9,
3.7481294368209543`*^9}, {3.748129467139167*^9, 3.7481295142325625`*^9}, {
3.74812955769254*^9, 3.7481295596218224`*^9}, {3.7481295924717264`*^9,
3.7481296908713217`*^9}, {3.7481297347185574`*^9, 3.748129753167857*^9}, {
3.748129792152842*^9, 3.7481297962826004`*^9}, {3.7481302715634537`*^9,
3.7481303043653173`*^9}, {3.74813033671789*^9, 3.7481303857835965`*^9}, {
3.7481304209900675`*^9, 3.7481306035127516`*^9}, {3.7481307576545143`*^9,
3.748130803684198*^9}, {3.748130933242569*^9, 3.748131189720868*^9}, {
3.7481312339608393`*^9, 3.7481312579778476`*^9}, {3.7481314121627865`*^9,
3.7481314424159546`*^9}, {3.74813152004771*^9, 3.7481315884403048`*^9}, {
3.748131720316221*^9, 3.748131723483329*^9}, {3.7481318360673876`*^9,
3.748131881181465*^9}, 3.748139274328088*^9, {3.7482088041999817`*^9,
3.748208806899802*^9}, {3.748208871956608*^9, 3.7482089009628386`*^9}, {
3.7482091301487274`*^9, 3.748209189164349*^9}, {3.748211621507584*^9,
3.7482116675245295`*^9}, {3.748212140123417*^9, 3.7482121735927324`*^9}, {
3.748311378730442*^9, 3.748311388949729*^9}},
CellLabel->"In[9]:=",ExpressionUUID->"0655997c-bf07-40ca-8a82-97dc34dd521c"],
Cell[BoxData[""], "Input",
CellChangeTimes->{3.7482120582013254`*^9, 3.748212138159733*^9},
CellLabel->"In[11]:=",ExpressionUUID->"6f3a9a41-4905-4769-b7a9-e37642735dd7"],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{
RowBox[{"Barycentric", "[",
RowBox[{"a_", ",", "b_", ",", "c_", ",", "xy_"}], "]"}], ":=",
"\[IndentingNewLine]",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{
"u", ",", "v", ",", "w", ",", "PBC", ",", "PAC", ",", "PAB", ",",
RowBox[{"bc", "=",
RowBox[{"{", "}"}]}]}], "}"}], ",", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{
"Calculate", " ", "barycentric", " ", "coordinates", " ", "of", " ",
"a", " ", "triangle"}], "*)"}], "\n",
RowBox[{
RowBox[{"PBC", "=",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"b", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"c", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"b", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"c", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], "}"}]}], ";", "\n",
RowBox[{"u", "=",
RowBox[{"0.5", " ", "*", " ",
RowBox[{"Det", "[", "PBC", "]"}]}]}], ";", "\[IndentingNewLine]",
RowBox[{"PAC", "=",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"a", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"c", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"a", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"c", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], "}"}]}], ";", "\n",
RowBox[{"v", "=",
RowBox[{"0.5", " ", "*", " ",
RowBox[{"Det", "[", "PAC", "]"}]}]}], ";", "\n",
RowBox[{"PAB", "=",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"1", ",", "1", ",", "1"}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"a", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"b", "[",
RowBox[{"[", "1", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",",
RowBox[{"{",
RowBox[{
RowBox[{"a", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"b", "[",
RowBox[{"[", "2", "]"}], "]"}], ",",
RowBox[{"xy", "[",
RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], "}"}]}], ";", "\n",
RowBox[{"w", "=",
RowBox[{"0.5", " ", "*", " ",
RowBox[{"Det", "[", "PAB", "]"}]}]}], ";", "\[IndentingNewLine]",
RowBox[{"AppendTo", "[",
RowBox[{"bc", ",", "u"}], "]"}], ";",
RowBox[{"AppendTo", "[",
RowBox[{"bc", ",", "v"}], "]"}], ";",
RowBox[{"AppendTo", "[",
RowBox[{"bc", ",", "w"}], "]"}], ";", "\[IndentingNewLine]", "bc"}]}],
"]"}]}], ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]"}]], "Input",
CellChangeTimes->{{3.7470049953768773`*^9, 3.747005055237352*^9}, {
3.7470051765349607`*^9, 3.747005227675456*^9}, {3.7470053367110405`*^9,
3.747005397308546*^9}, {3.747015245933696*^9, 3.747015250515238*^9}, {
3.7470152911176157`*^9, 3.7470153030098033`*^9}, 3.7470153343700833`*^9, {
3.747022007364908*^9, 3.7470220364890685`*^9}, 3.7470223883941584`*^9, {
3.747024421924423*^9, 3.747024475290842*^9}, {3.747024945674049*^9,
3.7470249736780434`*^9}, 3.747025040334417*^9, {3.7470251014734917`*^9,
3.747025284188378*^9}, {3.747025332051429*^9, 3.7470253957386217`*^9},
3.748119790273484*^9, {3.748119944241712*^9, 3.7481199574278708`*^9}, {
3.748122828727791*^9, 3.74812287402159*^9}, {3.748124185081509*^9,
3.7481242149897013`*^9}, {3.748124410155465*^9, 3.7481244111755886`*^9}, {
3.7481245463174105`*^9, 3.748124605353717*^9}, {3.7481273416618557`*^9,
3.7481273567578816`*^9}, {3.7481274803682556`*^9, 3.748127512281708*^9}, {
3.7481275500706525`*^9, 3.748127712078357*^9}, {3.7481278341194882`*^9,
3.748127851170933*^9}, {3.7481278936117907`*^9, 3.7481279269318466`*^9}, {
3.7481281876164637`*^9, 3.7481282449852376`*^9}, {3.74812828398666*^9,
3.748128432170235*^9}, {3.748128463303444*^9, 3.748128473439048*^9}, {
3.748128905984063*^9, 3.7481292297839303`*^9}, {3.7481292667695866`*^9,
3.7481294368209543`*^9}, {3.748129467139167*^9, 3.7481295142325625`*^9}, {
3.74812955769254*^9, 3.7481295596218224`*^9}, {3.7481295924717264`*^9,
3.7481296908713217`*^9}, {3.7481297347185574`*^9, 3.748129753167857*^9}, {
3.748129792152842*^9, 3.7481297962826004`*^9}, {3.7481302715634537`*^9,
3.7481303043653173`*^9}, {3.74813033671789*^9, 3.7481303857835965`*^9}, {
3.7481304209900675`*^9, 3.7481306035127516`*^9}, {3.7481307576545143`*^9,
3.748130803684198*^9}, {3.748130933242569*^9, 3.748131189720868*^9}, {
3.7481312339608393`*^9, 3.7481312579778476`*^9}, {3.7481314121627865`*^9,
3.7481314424159546`*^9}, {3.74813152004771*^9, 3.7481315884403048`*^9}, {
3.748131720316221*^9, 3.748131723483329*^9}, {3.7481318360673876`*^9,
3.748131881181465*^9}, 3.748139274328088*^9, 3.748205533698442*^9, {
3.748312776756742*^9, 3.7483128109615955`*^9}, {3.7483130072342744`*^9,
3.7483130233132296`*^9}, {3.7483140170300665`*^9, 3.748314017686349*^9}, {
3.748315483236636*^9,
3.7483154965407777`*^9}},ExpressionUUID->"af4564f0-1436-4e32-9e5c-\
b861498acc76"],
Cell[BoxData[
RowBox[{
RowBox[{
RowBox[{
RowBox[{"findPath", "[",
RowBox[{"p_", ",", "currentTri_"}], "]"}], ":=", "\[IndentingNewLine]",
RowBox[{"Module", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a", ",", "b", ",", "c", ",",
RowBox[{"current", "=", "currentTri"}], ",",
RowBox[{"reslist", "=",
RowBox[{"{", "}"}]}]}], "}"}], ",", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"AppendTo", "[",
RowBox[{"reslist", ",", "current"}], "]"}], ";",
" ",
RowBox[{"(*",
RowBox[{
"add", " ", "current", " ", "triangle", " ", "to", " ", "the", " ",
"path"}], " ", "*)"}], "\[IndentingNewLine]",
RowBox[{"a", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"b", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{"c", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"bary", "=",
RowBox[{"Barycentric", "[",
RowBox[{"a", ",", "b", ",", "c", ",", "p"}], "]"}]}], ";", " ",
RowBox[{"(*",
RowBox[{"find", " ", "the", " ", "barycentric", " ", "coordinates"}],
" ", "*)"}], "\[IndentingNewLine]",
RowBox[{"u", "=",
RowBox[{"bary", "[",
RowBox[{"[", "1", "]"}], "]"}]}], ";",
RowBox[{"v", "=",
RowBox[{"bary", "[",
RowBox[{"[", "2", "]"}], "]"}]}], ";",
RowBox[{"w", "=",
RowBox[{"bary", "[",
RowBox[{"[", "3", "]"}], "]"}]}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"Print", "[", "u", "]"}], ";", "\[IndentingNewLine]",
RowBox[{"Print", "[", "v", "]"}], ";", "\[IndentingNewLine]",
RowBox[{"Print", "[", "w", "]"}], ";", "\[IndentingNewLine]",
RowBox[{"While", "[",
RowBox[{
RowBox[{
RowBox[{"u", "<", "0"}], "||",
RowBox[{"v", "<", "0"}], "||",
RowBox[{"w", "<", "0"}]}], ",", " ",
RowBox[{"(*",
RowBox[{
"if", " ", "not", " ", "inside", " ", "the", " ", "triangle"}],
"*)"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"minpos", "=",
RowBox[{"Position", "[",
RowBox[{"bary", ",",
RowBox[{"Min", "[", "bary", "]"}]}], "]"}]}], ";", " ",
RowBox[{"(*",
RowBox[{
RowBox[{
"Find", " ", "the", " ", "position", " ", "of", " ", "min", " ",
"of", " ", "u"}], ",", "v", ",", "w"}], " ", "*)"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"minpos", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "\[Equal]", "1"}], ",",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"neighbor", "=",
RowBox[{"result", "[",
RowBox[{"[", "current", "]"}], "]"}]}], ";",
" ",
RowBox[{"(*",
RowBox[{
RowBox[{"In", " ", "case", " ", "u", " ", "is", " ", "min"}],
",",
RowBox[{
"Find", " ", "the", " ", "neighbour", " ", "that", " ",
"shares", " ", "edge", " ", "bc"}]}], " ", "*)"}],
"\[IndentingNewLine]", "\t",
RowBox[{
"Do", "[", "\[IndentingNewLine]", "\t", "\[IndentingNewLine]",
"\t",
RowBox[{
RowBox[{
RowBox[{"b1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{"c1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", "\t",
"\[IndentingNewLine]", " ",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"Length", "[",
RowBox[{"Intersection", "[",
RowBox[{
RowBox[{"{",
RowBox[{"b1", ",", "c1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"a", ",", "c", ",", "b"}], "}"}]}], "]"}], "]"}],
"\[Equal]", "2"}], ",",
RowBox[{"current", "=", "i"}]}], " ", "]"}], ";"}],
"\[IndentingNewLine]", " ", ",",
RowBox[{"{",
RowBox[{"i", ",", "neighbor"}], "}"}]}], "]"}], ";"}]}],
"\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"minpos", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "\[Equal]", "2"}], ",",
"\[IndentingNewLine]", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{"neighbor", "=",
RowBox[{"result", "[",
RowBox[{"[", "current", "]"}], "]"}]}], ";",
"\[IndentingNewLine]", "\t",
RowBox[{"Do", "[", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{
RowBox[{"a1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{"c1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", " ",
RowBox[{"(*",
RowBox[{
RowBox[{"If", " ", "v", " ", "is", " ", "min"}], ",",
RowBox[{
"Find", " ", "the", " ", "neighbour", " ", "that", " ",
"shares", " ", "edge", " ", "ac"}]}], " ", "*)"}],
"\[IndentingNewLine]", " ",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"Length", "[",
RowBox[{"Intersection", "[",
RowBox[{
RowBox[{"{",
RowBox[{"a1", ",", "c1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"a", ",", "c", ",", "b"}], "}"}]}], "]"}], "]"}],
"\[Equal]", "2"}], ",",
RowBox[{"current", "=", "i"}]}], " ", "]"}], ";"}],
"\[IndentingNewLine]", " ", ",",
RowBox[{"{",
RowBox[{"i", ",", "neighbor"}], "}"}]}], "]"}], ";"}]}],
"\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"minpos", "[",
RowBox[{"[",
RowBox[{"1", ",", "1"}], "]"}], "]"}], "\[Equal]", "3"}], ",",
"\[IndentingNewLine]", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{"neighbor", "=",
RowBox[{"result", "[",
RowBox[{"[", "current", "]"}], "]"}]}], ";",
"\[IndentingNewLine]", "\t",
RowBox[{"Do", "[", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{
RowBox[{"b1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{"a1", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", " ",
RowBox[{"(*",
RowBox[{
RowBox[{"If", " ", "w", " ", "is", " ", "min"}], ",",
RowBox[{
"Find", " ", "the", " ", "neighbour", " ", "that", " ",
"shares", " ", "edge", " ", "ab"}]}], " ", "*)"}],
"\[IndentingNewLine]", " ",
RowBox[{"If", "[",
RowBox[{
RowBox[{
RowBox[{"Length", "[",
RowBox[{"Intersection", "[",
RowBox[{
RowBox[{"{",
RowBox[{"b1", ",", "a1"}], "}"}], ",",
RowBox[{"{",
RowBox[{"a", ",", "c", ",", "b"}], "}"}]}], "]"}], "]"}],
"\[Equal]", "2"}], ",",
RowBox[{"current", "=", "i"}]}], " ", "]"}], ";"}],
"\[IndentingNewLine]", " ", ",",
RowBox[{"{",
RowBox[{"i", ",", "neighbor"}], "}"}]}], "]"}], ";"}]}],
"\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]",
RowBox[{"AppendTo", "[",
RowBox[{"reslist", ",", "current"}], "]"}], ";",
" ",
RowBox[{"(*",
RowBox[{
"add", " ", "current", " ", "triangle", " ", "to", " ", "the", " ",
"path"}], " ", "*)"}], "\[IndentingNewLine]",
RowBox[{"a", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]",
RowBox[{"b", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", " ",
RowBox[{"c", "=",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"current", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"bary", "=",
RowBox[{"Barycentric", "[",
RowBox[{"a", ",", "b", ",", "c", ",", "p"}], "]"}]}], ";",
"\[IndentingNewLine]",
RowBox[{"u", "=",
RowBox[{"bary", "[",
RowBox[{"[", "1", "]"}], "]"}]}], ";",
RowBox[{"v", "=",
RowBox[{"bary", "[",
RowBox[{"[", "2", "]"}], "]"}]}], ";",
RowBox[{"w", "=",
RowBox[{"bary", "[",
RowBox[{"[", "3", "]"}], "]"}]}], ";"}]}], "\[IndentingNewLine]",
"\[IndentingNewLine]", "]"}], ";", " ",
RowBox[{"(*",
RowBox[{"end", " ", "of", " ", "while"}], "*)"}],
"\[IndentingNewLine]", "reslist"}]}], "]"}]}], ";"}], " ",
RowBox[{"(*",
RowBox[{
"returns", " ", "a", " ", "list", " ", "of", " ", "triangles", " ", "as",
" ", "path", " ", "to", " ", "point"}], " ", "*)"}],
"\[IndentingNewLine]"}]], "Input",
CellChangeTimes->{{3.7470049953768773`*^9, 3.747005055237352*^9}, {
3.7470051765349607`*^9, 3.747005227675456*^9}, {3.7470053367110405`*^9,
3.747005397308546*^9}, {3.747015245933696*^9, 3.747015250515238*^9}, {
3.7470152911176157`*^9, 3.7470153030098033`*^9}, 3.7470153343700833`*^9, {
3.747022007364908*^9, 3.7470220364890685`*^9}, 3.7470223883941584`*^9, {
3.747024421924423*^9, 3.747024475290842*^9}, {3.747024945674049*^9,
3.7470249736780434`*^9}, 3.747025040334417*^9, {3.7470251014734917`*^9,
3.747025284188378*^9}, {3.747025332051429*^9, 3.7470253957386217`*^9},
3.748119790273484*^9, {3.748119944241712*^9, 3.7481199574278708`*^9}, {
3.748122828727791*^9, 3.74812287402159*^9}, {3.748124185081509*^9,
3.7481242149897013`*^9}, {3.748124410155465*^9, 3.7481244111755886`*^9}, {
3.7481245463174105`*^9, 3.748124605353717*^9}, {3.7481273416618557`*^9,
3.7481273567578816`*^9}, {3.7481274803682556`*^9, 3.748127512281708*^9}, {
3.7481275500706525`*^9, 3.748127712078357*^9}, {3.7481278341194882`*^9,
3.748127851170933*^9}, {3.7481278936117907`*^9, 3.7481279269318466`*^9}, {
3.7481281876164637`*^9, 3.7481282449852376`*^9}, {3.74812828398666*^9,
3.748128432170235*^9}, {3.748128463303444*^9, 3.748128473439048*^9}, {
3.748128905984063*^9, 3.7481292297839303`*^9}, {3.7481292667695866`*^9,
3.7481294368209543`*^9}, {3.748129467139167*^9, 3.7481295142325625`*^9}, {
3.74812955769254*^9, 3.7481295596218224`*^9}, {3.7481295924717264`*^9,
3.7481296908713217`*^9}, {3.7481297347185574`*^9, 3.748129753167857*^9}, {
3.748129792152842*^9, 3.7481297962826004`*^9}, {3.7481302715634537`*^9,
3.7481303043653173`*^9}, {3.74813033671789*^9, 3.7481303857835965`*^9}, {
3.7481304209900675`*^9, 3.7481306035127516`*^9}, {3.7481307576545143`*^9,
3.748130803684198*^9}, {3.748130933242569*^9, 3.748131189720868*^9}, {
3.7481312339608393`*^9, 3.7481312579778476`*^9}, {3.7481314121627865`*^9,
3.7481314424159546`*^9}, {3.74813152004771*^9, 3.7481315884403048`*^9}, {
3.748131720316221*^9, 3.748131723483329*^9}, {3.7481318360673876`*^9,
3.748131881181465*^9}, 3.748139274328088*^9, {3.748205533698442*^9,
3.748205554304706*^9}, {3.7483066806306562`*^9, 3.748306688218233*^9}, {
3.748306821768217*^9, 3.748306823446715*^9}, {3.7483070236609535`*^9,
3.748307023832867*^9}, 3.7483070563901873`*^9, {3.748307089140458*^9,
3.748307146036233*^9}, {3.7483072724498296`*^9, 3.7483072984709206`*^9}, {
3.7483073368521233`*^9, 3.7483073506111045`*^9}, {3.7483074118869376`*^9,
3.748307438683527*^9}, {3.748307575740055*^9, 3.7483077545304375`*^9}, {
3.748307972050829*^9, 3.7483080380747776`*^9}, 3.7483081176732903`*^9, {
3.7483081925225844`*^9, 3.748308239659139*^9}, {3.7483082806676188`*^9,
3.7483083012188997`*^9}, {3.7483083451638594`*^9,
3.7483084054702816`*^9}, {3.7483085380999603`*^9,
3.7483086082324843`*^9}, {3.748308779018137*^9, 3.7483088621300793`*^9}, {
3.7483089298083115`*^9, 3.7483091693686905`*^9}, {3.748309226639661*^9,
3.748309357776553*^9}, {3.7483094164778147`*^9, 3.7483095085090914`*^9}, {
3.748309553308765*^9, 3.7483095636351795`*^9}, {3.748309670425289*^9,
3.74830967713064*^9}, {3.748309729786603*^9, 3.748309792596175*^9}, {
3.7483098737526236`*^9, 3.7483099485174465`*^9}, {3.7483099830898385`*^9,
3.7483100162361813`*^9}, {3.7483100723025117`*^9, 3.748310082488331*^9}, {
3.7483102942650924`*^9, 3.748310294999504*^9}, {3.7483104382567086`*^9,
3.7483105356841455`*^9}, 3.7483108219486313`*^9, {3.748310945057926*^9,
3.7483109661527615`*^9}, {3.748311068137354*^9, 3.748311085794488*^9}, {
3.7483111302654653`*^9, 3.7483112141915674`*^9}, {3.7483112585687904`*^9,
3.748311359526972*^9}, {3.7483115040335927`*^9, 3.748311513612198*^9}, {
3.7483115674586396`*^9, 3.748311571474496*^9}, {3.7483116114764977`*^9,
3.74831165532242*^9}, {3.7483119501539793`*^9, 3.7483120243608217`*^9}, {
3.748312098520794*^9, 3.7483121498358397`*^9}, {3.7483122016822114`*^9,
3.748312405942441*^9}, {3.748312458210683*^9, 3.7483125511215863`*^9}, {
3.7483126149528847`*^9, 3.7483126549080353`*^9}, {3.7483128218840103`*^9,
3.7483128413068657`*^9}, 3.7483129435592203`*^9, {3.7483130320948906`*^9,
3.7483130398921604`*^9}, {3.748313197509729*^9, 3.7483134896181374`*^9}, {
3.7483135759037075`*^9, 3.7483135940296164`*^9}, {3.7483139552456975`*^9,
3.7483139665743904`*^9}, {3.748314117003799*^9, 3.748314177209937*^9}},
CellLabel->"In[13]:=",ExpressionUUID->"3ea02795-7455-4cca-8962-7c89dadc849a"],
Cell[BoxData[
RowBox[{"\[IndentingNewLine]", "\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*", " ",
RowBox[{"Plot", " ", "path", " ", "to", " ", "point"}], " ", "*)"}],
"\[IndentingNewLine]",
RowBox[{
RowBox[{
RowBox[{"currentTri", " ", "=", " ", "1"}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"findPoint", " ", "=", " ",
RowBox[{"pts", "[",
RowBox[{"[", "numpts", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{
RowBox[{"plotPoints", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Graphics", "[",
RowBox[{"{",
RowBox[{
RowBox[{"PointSize", "[", "0.05", "]"}], ",", "Black", ",",
RowBox[{"Point", "[",
RowBox[{"pts", "[",
RowBox[{"[", "i", "]"}], "]"}], "]"}]}], "}"}], "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "numpts"}], "}"}]}], "]"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{
RowBox[{"plotTris", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Graphics", "[",
RowBox[{"{",
RowBox[{"Black", ",",
RowBox[{"EdgeForm", "[", "Thick", "]"}], ",", "White", ",",
RowBox[{"Polygon", "[",
RowBox[{"{",
RowBox[{
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}], ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}], ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], "}"}], "]"}]}], "}"}], " ", "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",", "numtris"}], "}"}]}], "]"}]}], ";"}],
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{
RowBox[{"movingPoint", " ", "=", " ",
RowBox[{"pts", "[",
RowBox[{"[", "1", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]",
"\[IndentingNewLine]",
RowBox[{"Manipulate", "[", " ",
RowBox[{
RowBox[{"(", "\[IndentingNewLine]",
RowBox[{
RowBox[{"Print", "[",
RowBox[{"\"\<pos -\>\"", ",", "xy"}], "]"}], ";",
"\[IndentingNewLine]",
RowBox[{"plotMovingPoint", " ", "=", " ",
RowBox[{"Graphics", "[",
RowBox[{"{",
RowBox[{
RowBox[{"PointSize", "[", "0.05", "]"}], ",", "Red", ",",
RowBox[{"Point", "[", "xy", "]"}]}], "}"}], "]"}]}], ";",
"\[IndentingNewLine]", "\[IndentingNewLine]",
RowBox[{"(*",
RowBox[{
"call", " ", "findPath", " ", "that", " ", "returns", " ", "a", " ",
"list", " ", "of", " ", "triangles", " ", "in", " ", "the", " ",
"path"}], " ", "*)"}], "\[IndentingNewLine]", " ",
RowBox[{"plotPath", " ", "=", " ",
RowBox[{"Table", "[",
RowBox[{
RowBox[{"Graphics", "[",
RowBox[{"{",
RowBox[{"Black", ",",
RowBox[{"EdgeForm", "[", "Thick", "]"}], ",", "Blue", ",",
RowBox[{"Polygon", "[",
RowBox[{"{",
RowBox[{
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "1"}], "]"}], "]"}], "]"}],
"]"}], ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "2"}], "]"}], "]"}], "]"}],
"]"}], ",",
RowBox[{"pts", "[",
RowBox[{"[",
RowBox[{"tris", "[",
RowBox[{"[",
RowBox[{"i", ",", "1", ",", "3"}], "]"}], "]"}], "]"}],
"]"}]}], "}"}], "]"}]}], "}"}], " ", "]"}], ",",
RowBox[{"{",
RowBox[{"i", ",",
RowBox[{"findPath", "[",
RowBox[{"xy", ",", "currentTri"}], "]"}]}], "}"}]}], "]"}]}],
";", " ", "\[IndentingNewLine]",
RowBox[{"Show", "[",
RowBox[{"{",
RowBox[{
"plotTris", ",", "plotPoints", ",", " ", "plotMovingPoint", " ", ",",
"plotPath"}], "}"}], "]"}]}], "\[IndentingNewLine]", ")"}], ",",
"\[IndentingNewLine]",
RowBox[{"{",
RowBox[{
RowBox[{"{",
RowBox[{"xy", ",", "movingPoint"}], "}"}], ",", " ", "Locator"}],
"}"}]}], "]"}], "\[IndentingNewLine]", " ", "\[IndentingNewLine]",
"\[IndentingNewLine]", "\[IndentingNewLine]"}]}]], "Input",
CellChangeTimes->{{3.7470049953768773`*^9, 3.747005055237352*^9}, {
3.7470051765349607`*^9, 3.747005227675456*^9}, {3.7470053367110405`*^9,
3.747005397308546*^9}, {3.747015245933696*^9, 3.747015250515238*^9}, {
3.7470152911176157`*^9, 3.7470153030098033`*^9}, 3.7470153343700833`*^9, {
3.7470159353921804`*^9, 3.747015953332322*^9}, {3.7481392615325327`*^9,
3.7481392708854923`*^9}, {3.748139513434376*^9, 3.7481395208758445`*^9}, {
3.748139624583036*^9, 3.7481396763438683`*^9}, 3.748142095806926*^9, {
3.7481425467005167`*^9, 3.7481425599273353`*^9}, {3.748142603025071*^9,
3.748142620922003*^9}, {3.7481426537618914`*^9, 3.7481427118286023`*^9}, {
3.748143056526405*^9, 3.7481430902318754`*^9}, 3.748143143765565*^9, {
3.748143484801918*^9, 3.7481435226731653`*^9}, 3.7481456003294296`*^9,
3.748145745193119*^9, {3.7481853971070943`*^9, 3.7481854125993757`*^9}, {
3.7481879891486735`*^9, 3.7481880292815742`*^9}, {3.748188249194436*^9,
3.748188343521722*^9}, {3.748188418345373*^9, 3.748188453373931*^9}, {
3.748188483605251*^9, 3.748188484667797*^9}, {3.748188578290157*^9,
3.748188655661951*^9}, {3.7481891271275826`*^9, 3.7481891440936003`*^9},
3.748189207278572*^9, {3.7481893747554913`*^9, 3.74818945193285*^9}, {
3.748189493547437*^9, 3.7481895748332233`*^9}, {3.7481897616505995`*^9,
3.74818980026777*^9}, {3.748189925287834*^9, 3.748189937078749*^9}, {
3.748189967183465*^9, 3.74819012181607*^9}, {3.7481902015618744`*^9,
3.748190309225358*^9}, {3.7481904396955547`*^9, 3.7481905011235065`*^9}, {
3.7481914816905966`*^9, 3.7481915558317537`*^9}, {3.748191586369104*^9,
3.748191588450349*^9}, {3.7481918003972197`*^9, 3.748191868490615*^9}, {
3.748191932875538*^9, 3.7481919510336485`*^9}, {3.74819217839768*^9,
3.748192312274931*^9}, {3.748192357770183*^9, 3.7481923757083807`*^9}, {
3.7481924137518883`*^9, 3.748192555203307*^9}, {3.748192949415263*^9,
3.7481929624867153`*^9}, {3.748198522558142*^9, 3.7481985379243126`*^9}, {
3.7481986400863724`*^9, 3.7481986446064887`*^9}, {3.7481986768226027`*^9,
3.748198753704739*^9}, {3.7481997456442647`*^9, 3.748199755787608*^9}, {
3.748199961099552*^9, 3.7481999943196917`*^9}, {3.7482000391762376`*^9,
3.7482000511101894`*^9}, {3.748200247222015*^9, 3.7482002908340893`*^9}, {
3.7482006602625113`*^9, 3.74820067655818*^9}, {3.7482007894876738`*^9,