added core functionnalities

This commit is contained in:
Djalim Simaila 2023-04-17 11:30:46 +02:00
parent b5186aabed
commit ecccb0f8cb
10 changed files with 121218 additions and 193 deletions

1
.gitignore vendored
View File

@ -161,3 +161,4 @@ cython_debug/
#.idea/
*.DS_Store
.vscode

View File

@ -1,4 +1,4 @@
X (mm) Y (mm) Z (mm) téta (radian) rayon (mm) (xi-xmoy) (yi-ymoy)
X (mm) Y (mm) Z (mm) teta (radian) rayon (mm) (xi-xmoy) (yi-ymoy)
3,682017 -1,419335 0,000000 1,545182 11,430734 -11,426985 -0,292755
3,643013 -1,418564 0,008820 1,545337 11,469706 -11,465989 -0,291984
22,829306 -0,698036 0,009224 1,515344 7,732189 7,720304 0,428544

View File

@ -1,178 +1,178 @@
Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon écart type (mm)
15,109002 -1,126580 0,525629 6,530663 3,607419
14,759011 -1,362535 1,507908 6,832951 3,816242
14,399647 -1,876646 2,519127 7,203922 3,839974
14,833358 -2,294245 3,515291 7,659564 3,986682
14,551295 -2,921871 4,508631 8,124630 4,064604
14,719963 -3,489907 5,516487 8,611162 4,125672
15,653088 -3,576989 6,504377 9,088227 4,197464
15,528360 -3,217950 7,516899 9,679872 4,095008
15,197993 -3,206084 8,517862 9,856005 4,153453
15,226363 -3,100354 9,518580 9,814066 4,168109
15,254121 -3,033453 10,522295 9,801584 4,172651
15,109494 -2,990936 11,528812 9,818358 4,204343
15,258191 -2,948606 12,523704 9,793372 4,205091
15,260425 -2,846862 13,535485 9,931072 4,169460
15,246860 -2,755235 14,541483 9,922819 4,163184
15,059389 -2,655729 15,546262 9,901008 4,165597
15,251304 -2,609106 16,543563 9,959140 4,167041
15,097091 -2,539588 17,543546 9,868603 4,163034
15,093933 -2,443700 18,548111 9,976422 4,183186
14,949912 -2,438843 19,557546 9,933348 4,166028
14,966689 -2,349760 20,567689 9,938527 4,156936
14,950883 -2,340812 21,577084 9,905153 4,171345
15,096779 -2,345081 22,589863 9,932580 4,249029
14,806771 -2,289883 23,592947 9,852418 4,242787
14,952076 -2,257418 24,590853 9,876173 4,265370
15,028175 -2,121485 25,594171 9,959738 4,203711
14,982884 -2,071530 26,595360 9,989610 4,206300
14,795535 -2,032551 27,598803 10,041736 4,185772
14,787833 -1,875707 28,603350 9,959714 4,191609
14,679638 -1,891270 29,610567 9,956077 4,200592
14,889208 -1,826043 30,617457 9,993225 4,193690
14,520674 -1,831643 31,621881 9,952409 4,223428
14,542523 -1,751904 32,618383 9,883077 4,221861
14,575988 -1,746408 33,617804 9,984859 4,255401
14,804682 -1,750132 34,624611 9,819451 4,292567
14,490259 -1,642967 35,624215 9,953311 4,222367
14,735944 -1,554896 36,626529 10,013179 4,206921
14,544911 -1,492261 37,632446 9,983148 4,209558
14,537924 -1,407862 38,628970 10,007210 4,224915
14,459021 -1,413589 39,623974 10,056696 4,222635
14,341316 -1,351586 40,629093 9,973394 4,233831
14,329790 -1,354904 41,630937 9,973935 4,246349
14,234918 -1,266896 42,640187 9,948930 4,257650
14,259557 -1,280097 43,650348 9,849498 4,296699
14,519602 -1,216473 44,642000 10,031132 4,222810
14,372725 -1,108204 45,645576 10,014267 4,211337
14,281490 -1,107337 46,648306 10,044620 4,216833
14,336270 -0,987668 47,652177 10,015391 4,220645
14,061440 -0,951111 48,657390 10,013078 4,243399
13,973703 -0,916473 49,660216 9,981296 4,237155
13,968234 -0,932836 50,658363 9,937360 4,223044
14,055301 -0,873175 51,650006 9,879095 4,270257
13,989006 -0,841835 52,651135 9,848283 4,260065
14,044718 -0,792142 53,661702 10,047761 4,219088
14,101865 -0,685372 54,667333 10,037430 4,194381
14,005478 -0,715686 55,664900 10,053149 4,220059
14,008335 -0,612270 56,669087 10,044416 4,231616
13,597913 -0,671678 57,682024 9,904535 4,247681
13,758743 -0,657451 58,694046 9,813402 4,310536
13,895865 -0,482509 59,688670 9,983347 4,211743
13,627155 -0,414306 60,689153 10,022728 4,217149
13,830957 -0,453404 61,688298 10,000406 4,179492
13,888469 -0,442904 62,688772 10,157157 4,230888
13,584361 -0,345312 63,697018 9,998807 4,242081
13,438196 -0,356071 64,703368 9,966791 4,274805
13,505441 -0,447218 65,709630 9,704916 4,315932
13,558776 -0,242158 66,698778 9,993227 4,243046
13,554158 -0,238295 67,705061 10,108577 4,197977
13,583527 -0,244174 68,711600 10,121438 4,235825
13,524652 -0,169791 69,715192 10,055955 4,243012
13,330992 -0,128253 70,715926 10,008098 4,247463
13,415166 -0,265526 71,726594 9,765737 4,334063
13,185144 -0,123700 72,718564 9,946123 4,258158
13,409811 -0,015960 73,722364 10,059679 4,216258
13,131528 0,014875 74,730956 10,091098 4,204106
13,299486 -0,003694 75,724849 10,043816 4,201667
13,088395 0,039457 76,731238 10,038822 4,245121
13,087527 -0,152900 77,737956 9,715378 4,350332
13,167973 0,069414 78,735610 10,006142 4,236877
12,939653 0,157487 79,735304 9,937192 4,207233
13,126073 0,193690 80,736340 10,110119 4,156758
13,053833 0,152730 81,739029 10,094964 4,192648
12,989130 0,108005 82,753163 9,989712 4,234487
12,893875 0,079679 83,739788 9,749109 4,304357
13,086601 0,256718 84,751794 9,973849 4,207411
12,931981 0,306631 85,759612 10,052514 4,221452
12,847791 0,282018 86,757052 10,090841 4,159044
12,688440 0,200931 87,755245 10,031183 4,249346
12,805280 0,170540 88,749605 9,799148 4,293311
12,811539 0,320010 89,760393 10,026804 4,237193
12,641032 0,389605 90,758161 9,948139 4,224205
12,735854 0,418498 91,755392 10,152799 4,207888
12,560243 0,413689 92,760476 10,202650 4,206063
12,609439 0,226008 93,780309 9,786958 4,338638
12,682294 0,438632 94,773631 9,998334 4,242989
12,581374 0,458305 95,783579 10,032438 4,245805
12,592174 0,549772 96,781078 10,044376 4,243337
12,469647 0,590136 97,785563 10,201330 4,206622
12,278158 0,543662 98,786350 10,137950 4,213484
12,401176 0,375240 99,793588 9,827270 4,358727
12,276941 0,559409 100,794913 9,952292 4,214591
12,265753 0,657763 101,791011 10,042718 4,251309
12,210045 0,685234 102,789560 10,088843 4,232235
12,324426 0,708372 103,798752 10,187825 4,189629
12,315827 0,486894 104,812198 9,880219 4,355616
12,061925 0,673417 105,817564 9,957433 4,223332
11,990555 0,701699 106,817966 10,128935 4,245898
12,110466 0,820314 107,825450 10,034168 4,266755
12,199690 0,840051 108,821832 10,133930 4,185005
11,951099 0,630542 109,840068 9,948538 4,333887
11,927495 0,733485 110,847587 10,012946 4,228439
12,004672 0,803959 111,842180 10,104448 4,227028
11,762149 0,871957 112,843093 10,064753 4,261222
11,964982 0,900771 113,838806 10,150728 4,239924
11,819879 0,719631 114,851352 9,936334 4,319592
11,747868 0,786828 115,857587 10,051963 4,237287
11,691850 0,893021 116,854672 10,111003 4,248008
11,626320 0,937953 117,860246 10,103942 4,256986
11,835314 1,002212 118,861854 10,115098 4,245186
11,620574 0,867794 119,874049 9,933158 4,300609
11,606447 0,870904 120,879869 10,128911 4,228016
11,526915 0,952239 121,887422 10,071857 4,237201
11,511266 1,040808 122,889016 10,107100 4,248771
11,381419 1,079807 123,883982 10,106747 4,248992
11,506885 0,923174 124,887046 9,898147 4,283122
11,365852 0,926310 125,900430 10,128239 4,237896
11,115964 1,024597 126,894745 10,081134 4,258387
11,373757 1,070605 127,894651 10,129446 4,249336
11,260053 1,114556 128,899749 10,056654 4,274180
11,375340 1,030460 129,901580 10,009353 4,278422
11,254307 0,998204 130,920152 10,140535 4,233361
11,044813 1,111341 131,922046 10,075403 4,248869
11,188145 1,182453 132,925036 10,144068 4,235711
11,005896 1,094258 133,929816 9,934068 4,330953
11,162843 1,146518 134,935655 10,131322 4,198629
10,975650 1,114199 135,955183 10,090500 4,229270
10,809068 1,156069 136,957378 10,082341 4,245309
11,008931 1,258797 137,955524 10,159843 4,266746
10,874818 1,066434 138,949978 9,983696 4,325790
10,710381 1,158554 139,952849 10,127230 4,208446
10,702925 1,169479 140,965925 10,081024 4,243637
10,810022 1,232499 141,978216 10,144242 4,233022
10,534719 1,166943 142,984315 9,927271 4,328029
10,653399 1,220514 143,976565 10,078389 4,209338
10,664645 1,192991 144,983904 10,140095 4,197326
10,492488 1,253040 145,986733 10,122281 4,243284
10,490449 1,240018 146,999544 10,032701 4,298585
10,282415 1,233968 147,984404 9,972115 4,248330
10,614685 1,200489 148,990909 10,130152 4,201773
10,287664 1,282865 149,997136 10,093682 4,210225
10,194584 1,246998 151,010747 10,057248 4,269559
10,288588 1,239237 151,997174 9,957922 4,284220
10,369669 1,236405 153,004458 10,158683 4,205495
10,203128 1,305835 154,016447 10,041957 4,186064
10,077256 1,278711 155,014040 10,063914 4,226210
10,135129 1,260964 156,008626 9,926886 4,302899
10,042093 1,223902 157,022659 10,129376 4,185543
9,830513 1,414374 158,036166 10,146254 4,083820
9,558141 6,378917 159,064452 7,415959 4,059519
9,743941 3,945611 160,022127 11,299317 2,816085
9,687002 4,203672 161,035367 11,305097 2,688674
5,983897 4,073892 162,149639 7,679328 4,354927
15,737754 4,046555 162,836130 5,319269 2,502216
9,989533 5,106733 164,039987 5,084422 1,788357
9,938438 4,882785 165,042466 4,948148 1,781012
9,771705 5,044253 166,112646 4,365469 2,188756
9,818607 5,144202 166,995806 4,241973 2,171942
9,717684 5,032810 168,029887 5,092263 1,823993
9,587773 5,036715 169,075739 5,037209 1,778841
9,511125 4,898296 170,099644 4,018578 2,309374
9,476761 5,237496 171,029114 4,776665 1,914125
9,499023 4,847108 172,046103 4,952040 1,825549
9,269924 5,051201 173,073348 4,900214 1,791515
9,321049 5,216894 174,079443 4,895144 1,754269
9,212926 5,009517 175,079278 4,849661 1,655365
9,034164 5,071011 176,082819 4,624629 1,466621
9,072438 4,994180 177,099753 4,185767 1,170936
Xmoy (mm) Ymoy (mm) Zmoy (mm) rayon moyen (mm) rayon ecart type (mm)
15,109002 -1,126580 0,525629 6,530663 3,607419
14,759011 -1,362535 1,507908 6,832951 3,816242
14,399647 -1,876646 2,519127 7,203922 3,839974
14,833358 -2,294245 3,515291 7,659564 3,986682
14,551295 -2,921871 4,508631 8,124630 4,064604
14,719963 -3,489907 5,516487 8,611162 4,125672
15,653088 -3,576989 6,504377 9,088227 4,197464
15,528360 -3,217950 7,516899 9,679872 4,095008
15,197993 -3,206084 8,517862 9,856005 4,153453
15,226363 -3,100354 9,518580 9,814066 4,168109
15,254121 -3,033453 10,522295 9,801584 4,172651
15,109494 -2,990936 11,528812 9,818358 4,204343
15,258191 -2,948606 12,523704 9,793372 4,205091
15,260425 -2,846862 13,535485 9,931072 4,169460
15,246860 -2,755235 14,541483 9,922819 4,163184
15,059389 -2,655729 15,546262 9,901008 4,165597
15,251304 -2,609106 16,543563 9,959140 4,167041
15,097091 -2,539588 17,543546 9,868603 4,163034
15,093933 -2,443700 18,548111 9,976422 4,183186
14,949912 -2,438843 19,557546 9,933348 4,166028
14,966689 -2,349760 20,567689 9,938527 4,156936
14,950883 -2,340812 21,577084 9,905153 4,171345
15,096779 -2,345081 22,589863 9,932580 4,249029
14,806771 -2,289883 23,592947 9,852418 4,242787
14,952076 -2,257418 24,590853 9,876173 4,265370
15,028175 -2,121485 25,594171 9,959738 4,203711
14,982884 -2,071530 26,595360 9,989610 4,206300
14,795535 -2,032551 27,598803 10,041736 4,185772
14,787833 -1,875707 28,603350 9,959714 4,191609
14,679638 -1,891270 29,610567 9,956077 4,200592
14,889208 -1,826043 30,617457 9,993225 4,193690
14,520674 -1,831643 31,621881 9,952409 4,223428
14,542523 -1,751904 32,618383 9,883077 4,221861
14,575988 -1,746408 33,617804 9,984859 4,255401
14,804682 -1,750132 34,624611 9,819451 4,292567
14,490259 -1,642967 35,624215 9,953311 4,222367
14,735944 -1,554896 36,626529 10,013179 4,206921
14,544911 -1,492261 37,632446 9,983148 4,209558
14,537924 -1,407862 38,628970 10,007210 4,224915
14,459021 -1,413589 39,623974 10,056696 4,222635
14,341316 -1,351586 40,629093 9,973394 4,233831
14,329790 -1,354904 41,630937 9,973935 4,246349
14,234918 -1,266896 42,640187 9,948930 4,257650
14,259557 -1,280097 43,650348 9,849498 4,296699
14,519602 -1,216473 44,642000 10,031132 4,222810
14,372725 -1,108204 45,645576 10,014267 4,211337
14,281490 -1,107337 46,648306 10,044620 4,216833
14,336270 -0,987668 47,652177 10,015391 4,220645
14,061440 -0,951111 48,657390 10,013078 4,243399
13,973703 -0,916473 49,660216 9,981296 4,237155
13,968234 -0,932836 50,658363 9,937360 4,223044
14,055301 -0,873175 51,650006 9,879095 4,270257
13,989006 -0,841835 52,651135 9,848283 4,260065
14,044718 -0,792142 53,661702 10,047761 4,219088
14,101865 -0,685372 54,667333 10,037430 4,194381
14,005478 -0,715686 55,664900 10,053149 4,220059
14,008335 -0,612270 56,669087 10,044416 4,231616
13,597913 -0,671678 57,682024 9,904535 4,247681
13,758743 -0,657451 58,694046 9,813402 4,310536
13,895865 -0,482509 59,688670 9,983347 4,211743
13,627155 -0,414306 60,689153 10,022728 4,217149
13,830957 -0,453404 61,688298 10,000406 4,179492
13,888469 -0,442904 62,688772 10,157157 4,230888
13,584361 -0,345312 63,697018 9,998807 4,242081
13,438196 -0,356071 64,703368 9,966791 4,274805
13,505441 -0,447218 65,709630 9,704916 4,315932
13,558776 -0,242158 66,698778 9,993227 4,243046
13,554158 -0,238295 67,705061 10,108577 4,197977
13,583527 -0,244174 68,711600 10,121438 4,235825
13,524652 -0,169791 69,715192 10,055955 4,243012
13,330992 -0,128253 70,715926 10,008098 4,247463
13,415166 -0,265526 71,726594 9,765737 4,334063
13,185144 -0,123700 72,718564 9,946123 4,258158
13,409811 -0,015960 73,722364 10,059679 4,216258
13,131528 0,014875 74,730956 10,091098 4,204106
13,299486 -0,003694 75,724849 10,043816 4,201667
13,088395 0,039457 76,731238 10,038822 4,245121
13,087527 -0,152900 77,737956 9,715378 4,350332
13,167973 0,069414 78,735610 10,006142 4,236877
12,939653 0,157487 79,735304 9,937192 4,207233
13,126073 0,193690 80,736340 10,110119 4,156758
13,053833 0,152730 81,739029 10,094964 4,192648
12,989130 0,108005 82,753163 9,989712 4,234487
12,893875 0,079679 83,739788 9,749109 4,304357
13,086601 0,256718 84,751794 9,973849 4,207411
12,931981 0,306631 85,759612 10,052514 4,221452
12,847791 0,282018 86,757052 10,090841 4,159044
12,688440 0,200931 87,755245 10,031183 4,249346
12,805280 0,170540 88,749605 9,799148 4,293311
12,811539 0,320010 89,760393 10,026804 4,237193
12,641032 0,389605 90,758161 9,948139 4,224205
12,735854 0,418498 91,755392 10,152799 4,207888
12,560243 0,413689 92,760476 10,202650 4,206063
12,609439 0,226008 93,780309 9,786958 4,338638
12,682294 0,438632 94,773631 9,998334 4,242989
12,581374 0,458305 95,783579 10,032438 4,245805
12,592174 0,549772 96,781078 10,044376 4,243337
12,469647 0,590136 97,785563 10,201330 4,206622
12,278158 0,543662 98,786350 10,137950 4,213484
12,401176 0,375240 99,793588 9,827270 4,358727
12,276941 0,559409 100,794913 9,952292 4,214591
12,265753 0,657763 101,791011 10,042718 4,251309
12,210045 0,685234 102,789560 10,088843 4,232235
12,324426 0,708372 103,798752 10,187825 4,189629
12,315827 0,486894 104,812198 9,880219 4,355616
12,061925 0,673417 105,817564 9,957433 4,223332
11,990555 0,701699 106,817966 10,128935 4,245898
12,110466 0,820314 107,825450 10,034168 4,266755
12,199690 0,840051 108,821832 10,133930 4,185005
11,951099 0,630542 109,840068 9,948538 4,333887
11,927495 0,733485 110,847587 10,012946 4,228439
12,004672 0,803959 111,842180 10,104448 4,227028
11,762149 0,871957 112,843093 10,064753 4,261222
11,964982 0,900771 113,838806 10,150728 4,239924
11,819879 0,719631 114,851352 9,936334 4,319592
11,747868 0,786828 115,857587 10,051963 4,237287
11,691850 0,893021 116,854672 10,111003 4,248008
11,626320 0,937953 117,860246 10,103942 4,256986
11,835314 1,002212 118,861854 10,115098 4,245186
11,620574 0,867794 119,874049 9,933158 4,300609
11,606447 0,870904 120,879869 10,128911 4,228016
11,526915 0,952239 121,887422 10,071857 4,237201
11,511266 1,040808 122,889016 10,107100 4,248771
11,381419 1,079807 123,883982 10,106747 4,248992
11,506885 0,923174 124,887046 9,898147 4,283122
11,365852 0,926310 125,900430 10,128239 4,237896
11,115964 1,024597 126,894745 10,081134 4,258387
11,373757 1,070605 127,894651 10,129446 4,249336
11,260053 1,114556 128,899749 10,056654 4,274180
11,375340 1,030460 129,901580 10,009353 4,278422
11,254307 0,998204 130,920152 10,140535 4,233361
11,044813 1,111341 131,922046 10,075403 4,248869
11,188145 1,182453 132,925036 10,144068 4,235711
11,005896 1,094258 133,929816 9,934068 4,330953
11,162843 1,146518 134,935655 10,131322 4,198629
10,975650 1,114199 135,955183 10,090500 4,229270
10,809068 1,156069 136,957378 10,082341 4,245309
11,008931 1,258797 137,955524 10,159843 4,266746
10,874818 1,066434 138,949978 9,983696 4,325790
10,710381 1,158554 139,952849 10,127230 4,208446
10,702925 1,169479 140,965925 10,081024 4,243637
10,810022 1,232499 141,978216 10,144242 4,233022
10,534719 1,166943 142,984315 9,927271 4,328029
10,653399 1,220514 143,976565 10,078389 4,209338
10,664645 1,192991 144,983904 10,140095 4,197326
10,492488 1,253040 145,986733 10,122281 4,243284
10,490449 1,240018 146,999544 10,032701 4,298585
10,282415 1,233968 147,984404 9,972115 4,248330
10,614685 1,200489 148,990909 10,130152 4,201773
10,287664 1,282865 149,997136 10,093682 4,210225
10,194584 1,246998 151,010747 10,057248 4,269559
10,288588 1,239237 151,997174 9,957922 4,284220
10,369669 1,236405 153,004458 10,158683 4,205495
10,203128 1,305835 154,016447 10,041957 4,186064
10,077256 1,278711 155,014040 10,063914 4,226210
10,135129 1,260964 156,008626 9,926886 4,302899
10,042093 1,223902 157,022659 10,129376 4,185543
9,830513 1,414374 158,036166 10,146254 4,083820
9,558141 6,378917 159,064452 7,415959 4,059519
9,743941 3,945611 160,022127 11,299317 2,816085
9,687002 4,203672 161,035367 11,305097 2,688674
5,983897 4,073892 162,149639 7,679328 4,354927
15,737754 4,046555 162,836130 5,319269 2,502216
9,989533 5,106733 164,039987 5,084422 1,788357
9,938438 4,882785 165,042466 4,948148 1,781012
9,771705 5,044253 166,112646 4,365469 2,188756
9,818607 5,144202 166,995806 4,241973 2,171942
9,717684 5,032810 168,029887 5,092263 1,823993
9,587773 5,036715 169,075739 5,037209 1,778841
9,511125 4,898296 170,099644 4,018578 2,309374
9,476761 5,237496 171,029114 4,776665 1,914125
9,499023 4,847108 172,046103 4,952040 1,825549
9,269924 5,051201 173,073348 4,900214 1,791515
9,321049 5,216894 174,079443 4,895144 1,754269
9,212926 5,009517 175,079278 4,849661 1,655365
9,034164 5,071011 176,082819 4,624629 1,466621
9,072438 4,994180 177,099753 4,185767 1,170936

View File

@ -1,3 +1,8 @@
from utils.math import utils
from utils.files import file_data
from utils.files import output
from utils.files import parsers
def main():
pass

120867
output.txt Normal file

File diff suppressed because it is too large Load Diff

80
utils/files/file_data.py Normal file
View File

@ -0,0 +1,80 @@
"""
This module contains the File class.
"""
class FaceNotGiven(Exception):
"""
Exception raised when no faces was given.
"""
class Object:
"""
This class is used to manage the data of the 3D object.
"""
def __init__(self, vertices, faces=None):
self.vertices = vertices
self.faces = faces
self.x = [vertex[0] for vertex in vertices]
self.y = [vertex[1] for vertex in vertices]
self.z = [vertex[2] for vertex in vertices]
def get_x(self)->list:
"""
Get the x coordinates of the object.
return: x coordinates
"""
return self.x
def get_y(self)->list:
"""
Get the y coordinates of the object.
return: y coordinates
"""
return self.y
def get_z(self)->list:
"""
Get the z coordinates of the object.
return: z coordinates
"""
return self.z
def get_vertices(self, sort:bool = False):
"""
Get the vertices of the object.
:param sort: Sort the vertices by z coordinate
:return: vertices
"""
vertices = self.vertices if not sort else sorted(self.vertices, key=lambda vertex: vertex[2])
return vertices
def get_discrete_vertices(self, step:float = 0.1):
"""
Discretize the vertices of the object.
:param step: Step of the discretization
:return: Discretized vertices
"""
current_interval = int(min(self.get_z()))
splitted_data = [[]]
for line in self.get_vertices(sort=True):
# TODO check distance instead of equality
if line[2] >= current_interval:
splitted_data.append([])
current_interval += step
splitted_data[-1].append(line)
return splitted_data
def get_faces(self)->list:
"""
Get the faces of the object.
:return: faces
"""
if self.faces is None:
raise FaceNotGiven('No faces was given')
return self.faces
def get_data(self)->dict:
"""
Get the data of the object.
:return: Data of the object
"""
return {'verticies': self.vertices, 'faces': self.faces, 'x': self.x, 'y': self.y, 'z': self.z}

13
utils/files/output.py Normal file
View File

@ -0,0 +1,13 @@
"""
This module is used to manage the output files of the program.
"""
def save_output_file(output_file:str, content:str):
"""
Save the output file.
:param output_file: Path to the output file
:param content: Content of the output file
"""
with open(output_file, 'w') as f:
f.write(content)

View File

@ -1,4 +1,9 @@
def parseOBJfiles(filePath:str,ratio:float = 1,cornered:bool = False)->dict:
"""
This module contains functions to parse files.
"""
from utils.files.file_data import Object
def parse_obj_files(file_path:str,ratio:float = 1,normalised:bool = False)->Object:
"""
Parse an OBJ file and return a dict with the vertices and faces
@ -7,7 +12,7 @@ def parseOBJfiles(filePath:str,ratio:float = 1,cornered:bool = False)->dict:
:param cornered: If True, the vertices will be cornered
:return: A dict with the vertices and faces
"""
with open(filePath, 'r') as f:
with open(file_path, 'r') as f:
x, y, z = [], [], []
triangles = []
data = f.readlines()
@ -19,19 +24,24 @@ def parseOBJfiles(filePath:str,ratio:float = 1,cornered:bool = False)->dict:
x.append(float(line.split()[1]) * ratio)
y.append(float(line.split()[2]) * ratio)
z.append(float(line.split()[3]) * ratio)
if cornered:
if normalised:
"""
xmin = min(x)
for i in range(len(x)):
x[i] -= xmin
for count, value in enumerate(x):
x[count] -= xmin
ymin = min(y)
for i in range(len(y)):
y[i] -= ymin
for count, value in enumerate(y):
y[count] -= ymin
"""
zmin = min(z)
for i in range(len(z)):
z[i] -= zmin
return {'x':x, 'y':y, 'z':z, 'faces':triangles, "verticies": zip(x,y,z)}
def parseXYZfiles(filePath: str, delimiter: str = ' ') -> dict:
for count, value in enumerate(z):
z[count] -= zmin
return Object(list(zip(x,y,z)), triangles)
def parse_xyz_files(file_path: str, delimiter: str = ' ') -> dict:
"""
Parses an xyz file and returns a dict containing the coordinates.
@ -40,9 +50,9 @@ def parseXYZfiles(filePath: str, delimiter: str = ' ') -> dict:
:return: A dictionary containing the coordinates.
"""
x , y , z = [], [], []
with open(filePath, 'r') as f:
with open(file_path, 'r') as f:
data = f.readlines()
x = [float(line.split(delimiter)[0]) for line in data]
y = [float(line.split(delimiter)[1]) for line in data]
z = [float(line.split(delimiter)[2]) for line in data]
return {'x':x, 'y':y, 'z':z, "verticies": zip(x,y,z)}
return Object(zip(x,y,z))

49
utils/math/utils.py Normal file
View File

@ -0,0 +1,49 @@
"""
This module contains some utility functions for math operations.
"""
import numpy as np
def get_mean(values:list):
"""
Get the mean of the values.
"""
return np.mean(values)
def get_x_y_mean(discrete_values:list):
"""
Get the mean of the x and y coordinates in the discrete range.
:param x: x coordinates
:param y: y coordinates
:return: mean of x and y coordinates in the discrete range
"""
x = [vertex[0] for vertex in discrete_values]
y = [vertex[1] for vertex in discrete_values]
z = [vertex[2] for vertex in discrete_values]
return get_mean(x), get_mean(y), get_mean(z)
def get_radius_from_x_y(xi:float, yi:float, x_mean:float, y_mean:float):
"""
Get the radius from the x and y coordinates.
:param xi: x coordinate
:param yi: y coordinate
:param x_mean: mean of x coordinates in the discrete range
:param y_mean: mean of y coordinates in the discrete range
:return: radius for this point
"""
return np.sqrt((xi - x_mean) ** 2 + (yi - y_mean) ** 2)
def get_teta_from_x_y(xi:float, yi:float, x_mean:float, y_mean:float):
"""
Get the teta from the x and y coordinates.
:param xi: x coordinate
:param yi: y coordinate
:param x_mean: mean of x coordinates in the discrete range
:param y_mean: mean of y coordinates in the discrete range
:return: teta for this point
"""
return np.arctan2((xi - x_mean)/(yi - y_mean))