jscad / csg.js

DEPRECATED: CSG Library for JSCAD (See the link below)
https://github.com/jscad/OpenJSCAD.org/tree/master/packages/modeling
MIT License
217 stars 56 forks source link

Difference result is not ideal #195

Closed FishOrBear closed 2 years ago

FishOrBear commented 4 years ago

ver:v0.7 or v2

image

test code:


let g1= geom3.fromPoints(
  [[[256.8389840042205,977.0948774556746,0],[1156.9999413406463,1740.4903394918074,0],[2189.5569405471892,1749.4525587300886,0]],[[1540.204584590158,258.0981275777449,0],[0.00005578156424235203,-0.000016953505109995604,0],[256.8389840042205,977.0948774556746,0]],[[2189.5569405471892,1749.4525587300886,0],[2353.1832833206267,1531.57102796837,0],[1540.204584590158,258.0981275777449,0]],[[1540.204584590158,258.0981275777449,0],[256.8389840042205,977.0948774556746,0],[2189.5569405471892,1749.4525587300886,0]],[[2189.5569405471892,1749.4525587300886,18],[1156.9999413406463,1740.4903394918074,18],[256.8389840042205,977.0948774556746,18]],[[256.8389840042205,977.0948774556746,18],[0.00005578156424235203,-0.000016953505109995604,18],[1540.204584590158,258.0981275777449,18]],[[1540.204584590158,258.0981275777449,18],[2353.1832833206267,1531.57102796837,18],[2189.5569405471892,1749.4525587300886,18]],[[2189.5569405471892,1749.4525587300886,18],[256.8389840042205,977.0948774556746,18],[1540.204584590158,258.0981275777449,18]],[[256.8389840042205,977.0948774556746,0],[0.00005578156424235203,-0.000016953505109995604,0],[256.8389840042205,977.0948774556746,18]],[[0.00005578156424235203,-0.000016953505109995604,0],[0.00005578156424235203,-0.000016953505109995604,18],[256.8389840042205,977.0948774556746,18]],[[0.00005578156424235203,-0.000016953505109995604,0],[1540.204584590158,258.0981275777449,0],[0.00005578156424235203,-0.000016953505109995604,18]],[[1540.204584590158,258.0981275777449,0],[1540.204584590158,258.0981275777449,18],[0.00005578156424235203,-0.000016953505109995604,18]],[[1540.204584590158,258.0981275777449,0],[2353.1832833206267,1531.57102796837,0],[1540.204584590158,258.0981275777449,18]],[[2353.1832833206267,1531.57102796837,0],[2353.1832833206267,1531.57102796837,18],[1540.204584590158,258.0981275777449,18]],[[2353.1832833206267,1531.57102796837,0],[2189.5569405471892,1749.4525587300886,0],[2353.1832833206267,1531.57102796837,18]],[[2189.5569405471892,1749.4525587300886,0],[2189.5569405471892,1749.4525587300886,18],[2353.1832833206267,1531.57102796837,18]],[[2189.5569405471892,1749.4525587300886,0],[1156.9999413406463,1740.4903394918074,0],[2189.5569405471892,1749.4525587300886,18]],[[1156.9999413406463,1740.4903394918074,0],[1156.9999413406463,1740.4903394918074,18],[2189.5569405471892,1749.4525587300886,18]],[[1156.9999413406463,1740.4903394918074,0],[256.8389840042205,977.0948774556746,0],[1156.9999413406463,1740.4903394918074,18]],[[256.8389840042205,977.0948774556746,0],[256.8389840042205,977.0948774556746,18],[1156.9999413406463,1740.4903394918074,18]]]
)

let g2 = geom3.fromPoints(
  [[[1580.6330208694544,977.9157087545029,0],[1380.7082772171107,577.0908033589951,0],[1238.3974099075404,855.4901888112656,0]],[[1022.4086174881066,1278.0240003804795,0],[1834.8297676956263,1243.8740675191514,0],[1580.6330208694544,977.9157087545029,0]],[[1164.4646630203333,977.9842359761826,0],[1174.9165749466029,969.5695020894639,0],[1184.7499031936732,960.4395506124131,0]],[[1141.915514460763,992.5046522359482,0],[1153.4460701858607,985.6419660787217,0],[1164.4646630203333,977.9842359761826,0]],[[1117.5498394882288,1003.7127210836045,0],[1129.9302658950892,998.5382215718857,0],[1141.915514460763,992.5046522359482,0]],[[1091.8510690843668,1011.3860456685654,0],[1104.8357272064295,1008.0024244527451,0],[1117.5498394882288,1003.7127210836045,0]],[[1065.329082957467,1015.3723890523545,0],[1078.660351268014,1013.8467695455186,0],[1091.8510690843668,1011.3860456685654,0]],[[1038.5100922500696,1015.5926649312607,0],[1051.923471919259,1015.9553205709092,0],[1065.329082957467,1015.3723890523545,0]],[[1011.9262032425012,1012.0424940328232,0],[1025.1555657302943,1014.2862226705186,0],[1038.5100922500696,1015.5926649312607,0]],[[986.1048607742395,1004.7923261861436,0],[998.8877205764855,1008.8726179341904,0],[1011.9262032425012,1012.0424940328232,0]],[[961.5583748733605,993.9860059957139,0],[973.6411080276574,999.8218977193467,0],[986.1048607742395,1004.7923261861436,0]],[[938.7737526809777,979.8379347066514,0],[949.916651240548,987.3136427144639,0],[961.5583748733605,993.9860059957139,0]],[[918.2030739700402,962.6288206319443,0],[928.1850380813684,971.59601423546,0],[938.7737526809777,979.8379347066514,0]],[[900.2544503128137,942.7000944356553,0],[908.8774361526574,952.9808714131943,0],[918.2030739700402,962.6288206319443,0]],[[657.8000130569543,705.9425642232529,0],[803.0444588577355,942.7000944356553,0],[900.2544503128137,942.7000944356553,0]],[[1167.5034661209193,675.4510786275498,0],[879.1298775589074,542.7586805562607,0],[657.8000130569543,705.9425642232529,0]],[[1180.358141413888,686.4353468160264,0],[1174.0527901565638,680.8004591207139,0],[1167.5034661209193,675.4510786275498,0]],[[1192.1876702224818,698.5167066793076,0],[1186.4070763504114,692.3446485738389,0],[1180.358141413888,686.4353468160264,0]],[[1202.8987526809779,711.5998823384873,0],[1197.6885094558802,704.9393293599717,0],[1192.1876702224818,698.5167066793076,0]],[[1212.4069390213099,725.5816938619248,0],[1207.8081231033411,718.4851820211045,0],[1202.8987526809779,711.5998823384873,0]],[[1220.6372322952357,740.3519041280381,0],[1216.686121455392,732.8753950337998,0],[1212.4069390213099,725.5816938619248,0]],[[1227.5247292434779,755.7940199117295,0],[1224.2524819290247,747.9964735250107,0],[1220.6372322952357,740.3519041280381,0]],[[1233.0151314651575,771.7862837056748,0],[1230.4475350296107,763.7291776876084,0],[1227.5247292434779,755.7940199117295,0]],[[1237.0651345169154,788.2025625447861,0],[1235.2224526321497,779.9494459371201,0],[1233.0151314651575,771.7862837056748,0]],[[1239.6428017532435,804.9134084920518,0],[1238.5395607864466,796.5293600301377,0],[1237.0651345169154,788.2025625447861,0]],[[1240.7277932083216,821.7870447377793,0],[1240.372690669259,813.3381788472764,0],[1239.6428017532435,804.9134084920518,0]],[[1240.3115792190638,838.6904041509263,0],[1240.707407466134,830.2433473806016,0],[1240.7277932083216,821.7870447377793,0]],[[1238.3974099075404,855.4901888112656,0],[1239.5410714065638,847.1115549842946,0],[1240.3115792190638,838.6904041509263,0]],[[1022.4086174881066,1278.0240003804795,0],[1580.6330208694544,977.9157087545029,0],[1238.3974099075404,855.4901888112656,0]],[[1141.915514460763,992.5046522359482,0],[1164.4646630203333,977.9842359761826,0],[1184.7499031936732,960.4395506124131,0]],[[1091.8510690843668,1011.3860456685654,0],[1117.5498394882288,1003.7127210836045,0],[1141.915514460763,992.5046522359482,0]],[[1038.5100922500696,1015.5926649312607,0],[1065.329082957467,1015.3723890523545,0],[1091.8510690843668,1011.3860456685654,0]],[[986.1048607742395,1004.7923261861436,0],[1011.9262032425012,1012.0424940328232,0],[1038.5100922500696,1015.5926649312607,0]],[[938.7737526809777,979.8379347066514,0],[961.5583748733605,993.9860059957139,0],[986.1048607742395,1004.7923261861436,0]],[[900.2544503128137,942.7000944356553,0],[918.2030739700402,962.6288206319443,0],[938.7737526809777,979.8379347066514,0]],[[1167.5034661209193,675.4510786275498,0],[657.8000130569543,705.9425642232529,0],[900.2544503128137,942.7000944356553,0]],[[1192.1876702224818,698.5167066793076,0],[1180.358141413888,686.4353468160264,0],[1167.5034661209193,675.4510786275498,0]],[[1212.4069390213099,725.5816938619248,0],[1202.8987526809779,711.5998823384873,0],[1192.1876702224818,698.5167066793076,0]],[[1227.5247292434779,755.7940199117295,0],[1220.6372322952357,740.3519041280381,0],[1212.4069390213099,725.5816938619248,0]],[[1237.0651345169154,788.2025625447861,0],[1233.0151314651575,771.7862837056748,0],[1227.5247292434779,755.7940199117295,0]],[[1240.7277932083216,821.7870447377793,0],[1239.6428017532435,804.9134084920518,0],[1237.0651345169154,788.2025625447861,0]],[[1238.3974099075404,855.4901888112656,0],[1240.3115792190638,838.6904041509263,0],[1240.7277932083216,821.7870447377793,0]],[[1091.8510690843668,1011.3860456685654,0],[1141.915514460763,992.5046522359482,0],[1184.7499031936732,960.4395506124131,0]],[[986.1048607742395,1004.7923261861436,0],[1038.5100922500696,1015.5926649312607,0],[1091.8510690843668,1011.3860456685654,0]],[[900.2544503128137,942.7000944356553,0],[938.7737526809777,979.8379347066514,0],[986.1048607742395,1004.7923261861436,0]],[[1192.1876702224818,698.5167066793076,0],[1167.5034661209193,675.4510786275498,0],[900.2544503128137,942.7000944356553,0]],[[1227.5247292434779,755.7940199117295,0],[1212.4069390213099,725.5816938619248,0],[1192.1876702224818,698.5167066793076,0]],[[1240.7277932083216,821.7870447377793,0],[1237.0651345169154,788.2025625447861,0],[1227.5247292434779,755.7940199117295,0]],[[986.1048607742395,1004.7923261861436,0],[1091.8510690843668,1011.3860456685654,0],[1184.7499031936732,960.4395506124131,0]],[[1192.1876702224818,698.5167066793076,0],[900.2544503128137,942.7000944356553,0],[986.1048607742395,1004.7923261861436,0]],[[1240.7277932083216,821.7870447377793,0],[1227.5247292434779,755.7940199117295,0],[1192.1876702224818,698.5167066793076,0]],[[1192.1876702224818,698.5167066793076,0],[986.1048607742395,1004.7923261861436,0],[1184.7499031936732,960.4395506124131,0]],[[1238.3974099075404,855.4901888112656,0],[1240.7277932083216,821.7870447377793,0],[1192.1876702224818,698.5167066793076,0]],[[1238.3974099075404,855.4901888112656,0],[1192.1876702224818,698.5167066793076,0],[1184.7499031936732,960.4395506124131,0]],[[1238.3974099075404,855.4901888112656,0],[1184.7499031936732,960.4395506124131,0],[1022.4086174881066,1278.0240003804795,0]],[[1238.3974099075404,855.4901888112656,18],[1380.7082772171107,577.0908033589951,18],[1580.6330208694544,977.9157087545029,18]],[[1580.6330208694544,977.9157087545029,18],[1834.8297676956263,1243.8740675191514,18],[1022.4086174881066,1278.0240003804795,18]],[[1184.7499031936732,960.4395506124131,18],[1174.9165749466029,969.5695020894639,18],[1164.4646630203333,977.9842359761826,18]],[[1164.4646630203333,977.9842359761826,18],[1153.4460701858607,985.6419660787217,18],[1141.915514460763,992.5046522359482,18]],[[1141.915514460763,992.5046522359482,18],[1129.9302658950892,998.5382215718857,18],[1117.5498394882288,1003.7127210836045,18]],[[1117.5498394882288,1003.7127210836045,18],[1104.8357272064295,1008.0024244527451,18],[1091.8510690843668,1011.3860456685654,18]],[[1091.8510690843668,1011.3860456685654,18],[1078.660351268014,1013.8467695455186,18],[1065.329082957467,1015.3723890523545,18]],[[1065.329082957467,1015.3723890523545,18],[1051.923471919259,1015.9553205709092,18],[1038.5100922500696,1015.5926649312607,18]],[[1038.5100922500696,1015.5926649312607,18],[1025.1555657302943,1014.2862226705186,18],[1011.9262032425012,1012.0424940328232,18]],[[1011.9262032425012,1012.0424940328232,18],[998.8877205764855,1008.8726179341904,18],[986.1048607742395,1004.7923261861436,18]],[[986.1048607742395,1004.7923261861436,18],[973.6411080276574,999.8218977193467,18],[961.5583748733605,993.9860059957139,18]],[[961.5583748733605,993.9860059957139,18],[949.916651240548,987.3136427144639,18],[938.7737526809777,979.8379347066514,18]],[[938.7737526809777,979.8379347066514,18],[928.1850380813684,971.59601423546,18],[918.2030739700402,962.6288206319443,18]],[[918.2030739700402,962.6288206319443,18],[908.8774361526574,952.9808714131943,18],[900.2544503128137,942.7000944356553,18]],[[900.2544503128137,942.7000944356553,18],[803.0444588577355,942.7000944356553,18],[657.8000130569543,705.9425642232529,18]],[[657.8000130569543,705.9425642232529,18],[879.1298775589074,542.7586805562607,18],[1167.5034661209193,675.4510786275498,18]],[[1167.5034661209193,675.4510786275498,18],[1174.0527901565638,680.8004591207139,18],[1180.358141413888,686.4353468160264,18]],[[1180.358141413888,686.4353468160264,18],[1186.4070763504114,692.3446485738389,18],[1192.1876702224818,698.5167066793076,18]],[[1192.1876702224818,698.5167066793076,18],[1197.6885094558802,704.9393293599717,18],[1202.8987526809779,711.5998823384873,18]],[[1202.8987526809779,711.5998823384873,18],[1207.8081231033411,718.4851820211045,18],[1212.4069390213099,725.5816938619248,18]],[[1212.4069390213099,725.5816938619248,18],[1216.686121455392,732.8753950337998,18],[1220.6372322952357,740.3519041280381,18]],[[1220.6372322952357,740.3519041280381,18],[1224.2524819290247,747.9964735250107,18],[1227.5247292434779,755.7940199117295,18]],[[1227.5247292434779,755.7940199117295,18],[1230.4475350296107,763.7291776876084,18],[1233.0151314651575,771.7862837056748,18]],[[1233.0151314651575,771.7862837056748,18],[1235.2224526321497,779.9494459371201,18],[1237.0651345169154,788.2025625447861,18]],[[1237.0651345169154,788.2025625447861,18],[1238.5395607864466,796.5293600301377,18],[1239.6428017532435,804.9134084920518,18]],[[1239.6428017532435,804.9134084920518,18],[1240.372690669259,813.3381788472764,18],[1240.7277932083216,821.7870447377793,18]],[[1240.7277932083216,821.7870447377793,18],[1240.707407466134,830.2433473806016,18],[1240.3115792190638,838.6904041509263,18]],[[1240.3115792190638,838.6904041509263,18],[1239.5410714065638,847.1115549842946,18],[1238.3974099075404,855.4901888112656,18]],[[1238.3974099075404,855.4901888112656,18],[1580.6330208694544,977.9157087545029,18],[1022.4086174881066,1278.0240003804795,18]],[[1184.7499031936732,960.4395506124131,18],[1164.4646630203333,977.9842359761826,18],[1141.915514460763,992.5046522359482,18]],[[1141.915514460763,992.5046522359482,18],[1117.5498394882288,1003.7127210836045,18],[1091.8510690843668,1011.3860456685654,18]],[[1091.8510690843668,1011.3860456685654,18],[1065.329082957467,1015.3723890523545,18],[1038.5100922500696,1015.5926649312607,18]],[[1038.5100922500696,1015.5926649312607,18],[1011.9262032425012,1012.0424940328232,18],[986.1048607742395,1004.7923261861436,18]],[[986.1048607742395,1004.7923261861436,18],[961.5583748733605,993.9860059957139,18],[938.7737526809777,979.8379347066514,18]],[[938.7737526809777,979.8379347066514,18],[918.2030739700402,962.6288206319443,18],[900.2544503128137,942.7000944356553,18]],[[900.2544503128137,942.7000944356553,18],[657.8000130569543,705.9425642232529,18],[1167.5034661209193,675.4510786275498,18]],[[1167.5034661209193,675.4510786275498,18],[1180.358141413888,686.4353468160264,18],[1192.1876702224818,698.5167066793076,18]],[[1192.1876702224818,698.5167066793076,18],[1202.8987526809779,711.5998823384873,18],[1212.4069390213099,725.5816938619248,18]],[[1212.4069390213099,725.5816938619248,18],[1220.6372322952357,740.3519041280381,18],[1227.5247292434779,755.7940199117295,18]],[[1227.5247292434779,755.7940199117295,18],[1233.0151314651575,771.7862837056748,18],[1237.0651345169154,788.2025625447861,18]],[[1237.0651345169154,788.2025625447861,18],[1239.6428017532435,804.9134084920518,18],[1240.7277932083216,821.7870447377793,18]],[[1240.7277932083216,821.7870447377793,18],[1240.3115792190638,838.6904041509263,18],[1238.3974099075404,855.4901888112656,18]],[[1184.7499031936732,960.4395506124131,18],[1141.915514460763,992.5046522359482,18],[1091.8510690843668,1011.3860456685654,18]],[[1091.8510690843668,1011.3860456685654,18],[1038.5100922500696,1015.5926649312607,18],[986.1048607742395,1004.7923261861436,18]],[[986.1048607742395,1004.7923261861436,18],[938.7737526809777,979.8379347066514,18],[900.2544503128137,942.7000944356553,18]],[[900.2544503128137,942.7000944356553,18],[1167.5034661209193,675.4510786275498,18],[1192.1876702224818,698.5167066793076,18]],[[1192.1876702224818,698.5167066793076,18],[1212.4069390213099,725.5816938619248,18],[1227.5247292434779,755.7940199117295,18]],[[1227.5247292434779,755.7940199117295,18],[1237.0651345169154,788.2025625447861,18],[1240.7277932083216,821.7870447377793,18]],[[1184.7499031936732,960.4395506124131,18],[1091.8510690843668,1011.3860456685654,18],[986.1048607742395,1004.7923261861436,18]],[[986.1048607742395,1004.7923261861436,18],[900.2544503128137,942.7000944356553,18],[1192.1876702224818,698.5167066793076,18]],[[1192.1876702224818,698.5167066793076,18],[1227.5247292434779,755.7940199117295,18],[1240.7277932083216,821.7870447377793,18]],[[1184.7499031936732,960.4395506124131,18],[986.1048607742395,1004.7923261861436,18],[1192.1876702224818,698.5167066793076,18]],[[1192.1876702224818,698.5167066793076,18],[1240.7277932083216,821.7870447377793,18],[1238.3974099075404,855.4901888112656,18]],[[1184.7499031936732,960.4395506124131,18],[1192.1876702224818,698.5167066793076,18],[1238.3974099075404,855.4901888112656,18]],[[1022.4086174881066,1278.0240003804795,18],[1184.7499031936732,960.4395506124131,18],[1238.3974099075404,855.4901888112656,18]],[[1238.3974099075404,855.4901888112656,0],[1380.7082772171107,577.0908033589951,0],[1238.3974099075404,855.4901888112656,18]],[[1380.7082772171107,577.0908033589951,0],[1380.7082772171107,577.0908033589951,18],[1238.3974099075404,855.4901888112656,18]],[[1380.7082772171107,577.0908033589951,0],[1580.6330208694544,977.9157087545029,0],[1380.7082772171107,577.0908033589951,18]],[[1580.6330208694544,977.9157087545029,0],[1580.6330208694544,977.9157087545029,18],[1380.7082772171107,577.0908033589951,18]],[[1580.6330208694544,977.9157087545029,0],[1834.8297676956263,1243.8740675191514,0],[1580.6330208694544,977.9157087545029,18]],[[1834.8297676956263,1243.8740675191514,0],[1834.8297676956263,1243.8740675191514,18],[1580.6330208694544,977.9157087545029,18]],[[1834.8297676956263,1243.8740675191514,0],[1022.4086174881066,1278.0240003804795,0],[1834.8297676956263,1243.8740675191514,18]],[[1022.4086174881066,1278.0240003804795,0],[1022.4086174881066,1278.0240003804795,18],[1834.8297676956263,1243.8740675191514,18]],[[1022.4086174881066,1278.0240003804795,0],[1184.7499031936732,960.4395506124131,0],[1022.4086174881066,1278.0240003804795,18]],[[1184.7499031936732,960.4395506124131,0],[1184.7499031936732,960.4395506124131,18],[1022.4086174881066,1278.0240003804795,18]],[[1184.7499031936732,960.4395506124131,0],[1174.9165749466029,969.5695020894639,0],[1184.7499031936732,960.4395506124131,18]],[[1174.9165749466029,969.5695020894639,0],[1174.9165749466029,969.5695020894639,18],[1184.7499031936732,960.4395506124131,18]],[[1174.9165749466029,969.5695020894639,0],[1164.4646630203333,977.9842359761826,0],[1174.9165749466029,969.5695020894639,18]],[[1164.4646630203333,977.9842359761826,0],[1164.4646630203333,977.9842359761826,18],[1174.9165749466029,969.5695020894639,18]],[[1164.4646630203333,977.9842359761826,0],[1153.4460701858607,985.6419660787217,0],[1164.4646630203333,977.9842359761826,18]],[[1153.4460701858607,985.6419660787217,0],[1153.4460701858607,985.6419660787217,18],[1164.4646630203333,977.9842359761826,18]],[[1153.4460701858607,985.6419660787217,0],[1141.915514460763,992.5046522359482,0],[1153.4460701858607,985.6419660787217,18]],[[1141.915514460763,992.5046522359482,0],[1141.915514460763,992.5046522359482,18],[1153.4460701858607,985.6419660787217,18]],[[1141.915514460763,992.5046522359482,0],[1129.9302658950892,998.5382215718857,0],[1141.915514460763,992.5046522359482,18]],[[1129.9302658950892,998.5382215718857,0],[1129.9302658950892,998.5382215718857,18],[1141.915514460763,992.5046522359482,18]],[[1129.9302658950892,998.5382215718857,0],[1117.5498394882288,1003.7127210836045,0],[1129.9302658950892,998.5382215718857,18]],[[1117.5498394882288,1003.7127210836045,0],[1117.5498394882288,1003.7127210836045,18],[1129.9302658950892,998.5382215718857,18]],[[1117.5498394882288,1003.7127210836045,0],[1104.8357272064295,1008.0024244527451,0],[1117.5498394882288,1003.7127210836045,18]],[[1104.8357272064295,1008.0024244527451,0],[1104.8357272064295,1008.0024244527451,18],[1117.5498394882288,1003.7127210836045,18]],[[1104.8357272064295,1008.0024244527451,0],[1091.8510690843668,1011.3860456685654,0],[1104.8357272064295,1008.0024244527451,18]],[[1091.8510690843668,1011.3860456685654,0],[1091.8510690843668,1011.3860456685654,18],[1104.8357272064295,1008.0024244527451,18]],[[1091.8510690843668,1011.3860456685654,0],[1078.660351268014,1013.8467695455186,0],[1091.8510690843668,1011.3860456685654,18]],[[1078.660351268014,1013.8467695455186,0],[1078.660351268014,1013.8467695455186,18],[1091.8510690843668,1011.3860456685654,18]],[[1078.660351268014,1013.8467695455186,0],[1065.329082957467,1015.3723890523545,0],[1078.660351268014,1013.8467695455186,18]],[[1065.329082957467,1015.3723890523545,0],[1065.329082957467,1015.3723890523545,18],[1078.660351268014,1013.8467695455186,18]],[[1065.329082957467,1015.3723890523545,0],[1051.923471919259,1015.9553205709092,0],[1065.329082957467,1015.3723890523545,18]],[[1051.923471919259,1015.9553205709092,0],[1051.923471919259,1015.9553205709092,18],[1065.329082957467,1015.3723890523545,18]],[[1051.923471919259,1015.9553205709092,0],[1038.5100922500696,1015.5926649312607,0],[1051.923471919259,1015.9553205709092,18]],[[1038.5100922500696,1015.5926649312607,0],[1038.5100922500696,1015.5926649312607,18],[1051.923471919259,1015.9553205709092,18]],[[1038.5100922500696,1015.5926649312607,0],[1025.1555657302943,1014.2862226705186,0],[1038.5100922500696,1015.5926649312607,18]],[[1025.1555657302943,1014.2862226705186,0],[1025.1555657302943,1014.2862226705186,18],[1038.5100922500696,1015.5926649312607,18]],[[1025.1555657302943,1014.2862226705186,0],[1011.9262032425012,1012.0424940328232,0],[1025.1555657302943,1014.2862226705186,18]],[[1011.9262032425012,1012.0424940328232,0],[1011.9262032425012,1012.0424940328232,18],[1025.1555657302943,1014.2862226705186,18]],[[1011.9262032425012,1012.0424940328232,0],[998.8877205764855,1008.8726179341904,0],[1011.9262032425012,1012.0424940328232,18]],[[998.8877205764855,1008.8726179341904,0],[998.8877205764855,1008.8726179341904,18],[1011.9262032425012,1012.0424940328232,18]],[[998.8877205764855,1008.8726179341904,0],[986.1048607742395,1004.7923261861436,0],[998.8877205764855,1008.8726179341904,18]],[[986.1048607742395,1004.7923261861436,0],[986.1048607742395,1004.7923261861436,18],[998.8877205764855,1008.8726179341904,18]],[[986.1048607742395,1004.7923261861436,0],[973.6411080276574,999.8218977193467,0],[986.1048607742395,1004.7923261861436,18]],[[973.6411080276574,999.8218977193467,0],[973.6411080276574,999.8218977193467,18],[986.1048607742395,1004.7923261861436,18]],[[973.6411080276574,999.8218977193467,0],[961.5583748733605,993.9860059957139,0],[973.6411080276574,999.8218977193467,18]],[[961.5583748733605,993.9860059957139,0],[961.5583748733605,993.9860059957139,18],[973.6411080276574,999.8218977193467,18]],[[961.5583748733605,993.9860059957139,0],[949.916651240548,987.3136427144639,0],[961.5583748733605,993.9860059957139,18]],[[949.916651240548,987.3136427144639,0],[949.916651240548,987.3136427144639,18],[961.5583748733605,993.9860059957139,18]],[[949.916651240548,987.3136427144639,0],[938.7737526809777,979.8379347066514,0],[949.916651240548,987.3136427144639,18]],[[938.7737526809777,979.8379347066514,0],[938.7737526809777,979.8379347066514,18],[949.916651240548,987.3136427144639,18]],[[938.7737526809777,979.8379347066514,0],[928.1850380813684,971.59601423546,0],[938.7737526809777,979.8379347066514,18]],[[928.1850380813684,971.59601423546,0],[928.1850380813684,971.59601423546,18],[938.7737526809777,979.8379347066514,18]],[[928.1850380813684,971.59601423546,0],[918.2030739700402,962.6288206319443,0],[928.1850380813684,971.59601423546,18]],[[918.2030739700402,962.6288206319443,0],[918.2030739700402,962.6288206319443,18],[928.1850380813684,971.59601423546,18]],[[918.2030739700402,962.6288206319443,0],[908.8774361526574,952.9808714131943,0],[918.2030739700402,962.6288206319443,18]],[[908.8774361526574,952.9808714131943,0],[908.8774361526574,952.9808714131943,18],[918.2030739700402,962.6288206319443,18]],[[908.8774361526574,952.9808714131943,0],[900.2544503128137,942.7000944356553,0],[908.8774361526574,952.9808714131943,18]],[[900.2544503128137,942.7000944356553,0],[900.2544503128137,942.7000944356553,18],[908.8774361526574,952.9808714131943,18]],[[900.2544503128137,942.7000944356553,0],[803.0444588577355,942.7000944356553,0],[900.2544503128137,942.7000944356553,18]],[[803.0444588577355,942.7000944356553,0],[803.0444588577355,942.7000944356553,18],[900.2544503128137,942.7000944356553,18]],[[803.0444588577355,942.7000944356553,0],[657.8000130569543,705.9425642232529,0],[803.0444588577355,942.7000944356553,18]],[[657.8000130569543,705.9425642232529,0],[657.8000130569543,705.9425642232529,18],[803.0444588577355,942.7000944356553,18]],[[657.8000130569543,705.9425642232529,0],[879.1298775589074,542.7586805562607,0],[657.8000130569543,705.9425642232529,18]],[[879.1298775589074,542.7586805562607,0],[879.1298775589074,542.7586805562607,18],[657.8000130569543,705.9425642232529,18]],[[879.1298775589074,542.7586805562607,0],[1167.5034661209193,675.4510786275498,0],[879.1298775589074,542.7586805562607,18]],[[1167.5034661209193,675.4510786275498,0],[1167.5034661209193,675.4510786275498,18],[879.1298775589074,542.7586805562607,18]],[[1167.5034661209193,675.4510786275498,0],[1174.0527901565638,680.8004591207139,0],[1167.5034661209193,675.4510786275498,18]],[[1174.0527901565638,680.8004591207139,0],[1174.0527901565638,680.8004591207139,18],[1167.5034661209193,675.4510786275498,18]],[[1174.0527901565638,680.8004591207139,0],[1180.358141413888,686.4353468160264,0],[1174.0527901565638,680.8004591207139,18]],[[1180.358141413888,686.4353468160264,0],[1180.358141413888,686.4353468160264,18],[1174.0527901565638,680.8004591207139,18]],[[1180.358141413888,686.4353468160264,0],[1186.4070763504114,692.3446485738389,0],[1180.358141413888,686.4353468160264,18]],[[1186.4070763504114,692.3446485738389,0],[1186.4070763504114,692.3446485738389,18],[1180.358141413888,686.4353468160264,18]],[[1186.4070763504114,692.3446485738389,0],[1192.1876702224818,698.5167066793076,0],[1186.4070763504114,692.3446485738389,18]],[[1192.1876702224818,698.5167066793076,0],[1192.1876702224818,698.5167066793076,18],[1186.4070763504114,692.3446485738389,18]],[[1192.1876702224818,698.5167066793076,0],[1197.6885094558802,704.9393293599717,0],[1192.1876702224818,698.5167066793076,18]],[[1197.6885094558802,704.9393293599717,0],[1197.6885094558802,704.9393293599717,18],[1192.1876702224818,698.5167066793076,18]],[[1197.6885094558802,704.9393293599717,0],[1202.8987526809779,711.5998823384873,0],[1197.6885094558802,704.9393293599717,18]],[[1202.8987526809779,711.5998823384873,0],[1202.8987526809779,711.5998823384873,18],[1197.6885094558802,704.9393293599717,18]],[[1202.8987526809779,711.5998823384873,0],[1207.8081231033411,718.4851820211045,0],[1202.8987526809779,711.5998823384873,18]],[[1207.8081231033411,718.4851820211045,0],[1207.8081231033411,718.4851820211045,18],[1202.8987526809779,711.5998823384873,18]],[[1207.8081231033411,718.4851820211045,0],[1212.4069390213099,725.5816938619248,0],[1207.8081231033411,718.4851820211045,18]],[[1212.4069390213099,725.5816938619248,0],[1212.4069390213099,725.5816938619248,18],[1207.8081231033411,718.4851820211045,18]],[[1212.4069390213099,725.5816938619248,0],[1216.686121455392,732.8753950337998,0],[1212.4069390213099,725.5816938619248,18]],[[1216.686121455392,732.8753950337998,0],[1216.686121455392,732.8753950337998,18],[1212.4069390213099,725.5816938619248,18]],[[1216.686121455392,732.8753950337998,0],[1220.6372322952357,740.3519041280381,0],[1216.686121455392,732.8753950337998,18]],[[1220.6372322952357,740.3519041280381,0],[1220.6372322952357,740.3519041280381,18],[1216.686121455392,732.8753950337998,18]],[[1220.6372322952357,740.3519041280381,0],[1224.2524819290247,747.9964735250107,0],[1220.6372322952357,740.3519041280381,18]],[[1224.2524819290247,747.9964735250107,0],[1224.2524819290247,747.9964735250107,18],[1220.6372322952357,740.3519041280381,18]],[[1224.2524819290247,747.9964735250107,0],[1227.5247292434779,755.7940199117295,0],[1224.2524819290247,747.9964735250107,18]],[[1227.5247292434779,755.7940199117295,0],[1227.5247292434779,755.7940199117295,18],[1224.2524819290247,747.9964735250107,18]],[[1227.5247292434779,755.7940199117295,0],[1230.4475350296107,763.7291776876084,0],[1227.5247292434779,755.7940199117295,18]],[[1230.4475350296107,763.7291776876084,0],[1230.4475350296107,763.7291776876084,18],[1227.5247292434779,755.7940199117295,18]],[[1230.4475350296107,763.7291776876084,0],[1233.0151314651575,771.7862837056748,0],[1230.4475350296107,763.7291776876084,18]],[[1233.0151314651575,771.7862837056748,0],[1233.0151314651575,771.7862837056748,18],[1230.4475350296107,763.7291776876084,18]],[[1233.0151314651575,771.7862837056748,0],[1235.2224526321497,779.9494459371201,0],[1233.0151314651575,771.7862837056748,18]],[[1235.2224526321497,779.9494459371201,0],[1235.2224526321497,779.9494459371201,18],[1233.0151314651575,771.7862837056748,18]],[[1235.2224526321497,779.9494459371201,0],[1237.0651345169154,788.2025625447861,0],[1235.2224526321497,779.9494459371201,18]],[[1237.0651345169154,788.2025625447861,0],[1237.0651345169154,788.2025625447861,18],[1235.2224526321497,779.9494459371201,18]],[[1237.0651345169154,788.2025625447861,0],[1238.5395607864466,796.5293600301377,0],[1237.0651345169154,788.2025625447861,18]],[[1238.5395607864466,796.5293600301377,0],[1238.5395607864466,796.5293600301377,18],[1237.0651345169154,788.2025625447861,18]],[[1238.5395607864466,796.5293600301377,0],[1239.6428017532435,804.9134084920518,0],[1238.5395607864466,796.5293600301377,18]],[[1239.6428017532435,804.9134084920518,0],[1239.6428017532435,804.9134084920518,18],[1238.5395607864466,796.5293600301377,18]],[[1239.6428017532435,804.9134084920518,0],[1240.372690669259,813.3381788472764,0],[1239.6428017532435,804.9134084920518,18]],[[1240.372690669259,813.3381788472764,0],[1240.372690669259,813.3381788472764,18],[1239.6428017532435,804.9134084920518,18]],[[1240.372690669259,813.3381788472764,0],[1240.7277932083216,821.7870447377793,0],[1240.372690669259,813.3381788472764,18]],[[1240.7277932083216,821.7870447377793,0],[1240.7277932083216,821.7870447377793,18],[1240.372690669259,813.3381788472764,18]],[[1240.7277932083216,821.7870447377793,0],[1240.707407466134,830.2433473806016,0],[1240.7277932083216,821.7870447377793,18]],[[1240.707407466134,830.2433473806016,0],[1240.707407466134,830.2433473806016,18],[1240.7277932083216,821.7870447377793,18]],[[1240.707407466134,830.2433473806016,0],[1240.3115792190638,838.6904041509263,0],[1240.707407466134,830.2433473806016,18]],[[1240.3115792190638,838.6904041509263,0],[1240.3115792190638,838.6904041509263,18],[1240.707407466134,830.2433473806016,18]],[[1240.3115792190638,838.6904041509263,0],[1239.5410714065638,847.1115549842946,0],[1240.3115792190638,838.6904041509263,18]],[[1239.5410714065638,847.1115549842946,0],[1239.5410714065638,847.1115549842946,18],[1240.3115792190638,838.6904041509263,18]],[[1239.5410714065638,847.1115549842946,0],[1238.3974099075404,855.4901888112656,0],[1239.5410714065638,847.1115549842946,18]],[[1238.3974099075404,855.4901888112656,0],[1238.3974099075404,855.4901888112656,18],[1239.5410714065638,847.1115549842946,18]]]
)
console.log(g2);

let ggg= subtract(g1,g2);
z3dev commented 4 years ago

@FishOrBear thanks again.

OK. I did some research on this issue. Here's what I found out.

If you scale() those shapes then the subtract works fine.

  g1 = transforms.scale([0.01, 0.01, 0.01], g1)
  g2 = transforms.scale([0.01, 0.01, 0.01], g2)

This is reenforcing my understanding of the logic inside the boolean routines. Basically, the booleans are optimized for units of 1. The LARGE size of your shapes are pushing the precision of the math being performed, and cause polygons to ignored or removed.

z3dev commented 4 years ago

I can reproduce this issue with two simple primitives, with large scale.

  let shape1 = primitives.cylinder({segments: 14, height: 18, startRadius: 2123.456789, endRadius: 2123.456789})
  let shape2 = primitives.cylinder({segments: 7, height: 18, startRadius: 512.3456789, endRadius: 512.3456789})
  let shape3 = booleans.subtract(shape1, shape2)

I'd like to keep this issue as a BUG. Is that fine?

FishOrBear commented 4 years ago

OK, thank you.

` Basically, the booleans are optimized for units of 1. ` This gave me some inspiration, would it be better to write this in the document? (Before not solving the problem)

z3dev commented 2 years ago

This will not be fixed. Please reopen issues at OpenJSCAD.org