{"id":358794,"date":"2024-05-21T00:19:19","date_gmt":"2024-05-21T00:19:19","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=358794"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T00:19:19","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=358794","title":{"rendered":"<span>\u041f\u043e\u0438\u0441\u043a \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0439 \u043c\u0435\u0436\u0434\u0443 \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c \u0438 \u043f\u0440\u044f\u043c\u043e\u0439 \u0438\u043b\u0438 \u043f\u0440\u044f\u043c\u043e\u0439 \u0438 \u043f\u0440\u044f\u043c\u043e\u0439 \u0432 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0432 turboprolog2.0, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043d\u0438\u0433\u0434\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/523440\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/a> \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u043c\u0443.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4f6\/219\/409\/4f621940995661943a20cb384332216d.png\" alt=\"\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c\" title=\"\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c\" width=\"672\" height=\"491\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4f6\/219\/409\/4f621940995661943a20cb384332216d.png\"\/><\/p>\n<div><figcaption>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u0437\u0430\u0434\u0430\u043d\u0430 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 P00 \u0438 P01,\u0430 \u0432\u0442\u043e\u0440\u0430\u044f &#8212; \u042010 \u0438 \u042011. \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u0434\u0430\u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 X,Y,Z (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, P00 &#8212; X00,Y00,Z00). \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u0447\u043a\u0443 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u0430\u044f \u0438\u043c\u0435\u0435\u0442\u0441\u044f. \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043b\u0438 \u043e\u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043e\u0442\u0440\u0435\u0437\u043a\u0443 \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 (\u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439).<\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 DP0 \u0438 DP1, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0438\u043c \u043f\u0440\u044f\u043c\u044b\u043c. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"python\"># \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX0 = X01 - X00 DY0 = Y01 - Y00 DZ0 = Z01 - Z00 # \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX1 = X11 - X10 DY1 = Y11 - Y10 DZ1 = Z11 - Z10<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043e\u0431\u0435\u0438\u043c \u043f\u0440\u044f\u043c\u044b\u043c (\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e?), \u0438 \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439.<\/p>\n<p>P = P00 + DP0 * t  =  P10 + DP1 * s<\/p>\n<p>\u0420\u0430\u0437\u043b\u043e\u0436\u0438\u043c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<p>X00 + DX0 * t  =  X10 + DX1 * s<\/p>\n<p>Y00 + DY0 * t  =  Y10 + DY1 * s<\/p>\n<p>Z00 + DZ0 * t  =  Z10 + DZ1 * s<\/p>\n<p>\u0423\u0434\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>DX0 * t  &#8212; DX1 * s = X10 &#8212; X00<\/p>\n<p>DY0 * t  &#8212; DY1 * s = Y10 &#8212; Y00<\/p>\n<p>DZ0 * t  &#8212; DZ1 * s = Z10 &#8212; Z00<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0442\u043e \u0447\u0435\u0440\u0435\u0437 s \u0438\u043b\u0438 t \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/60e\/b02\/163\/60eb02163b16c55610fb1be43a2d6135.png\" width=\"331\" height=\"144\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/60e\/b02\/163\/60eb02163b16c55610fb1be43a2d6135.png\"\/><\/figure>\n<p>\u041a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u043b\u043e\u043f\u043d\u0443\u0442\u044c.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/49f\/65c\/aac\/49f65caac04eab8915bd255bd65e8933.png\" width=\"470\" height=\"184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/49f\/65c\/aac\/49f65caac04eab8915bd255bd65e8933.png\"\/><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0440\u0435\u0448\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u041a\u0440\u0430\u043c\u0435\u0440\u0430, \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043a\u043e\u0434 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 Python.<\/p>\n<pre><code class=\"python\"># \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f X00 = 0 Y00 = 0 Z00 = 0 X01 = 0 Y01 = 0 Z01 = 5 # \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f X10 = 5 Y10 = 0 Z10 = 0 X11 = 5 Y11 = 0 Z11 = 5  # \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX0 = X01 - X00 DY0 = Y01 - Y00 DZ0 = Z01 - Z00 # \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX1 = X11 - X10 DY1 = Y11 - Y10 DZ1 = Z11 - Z10  # \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b A = DX0 B = -DX1 C = X10 - X00 D = DY0 E = -DY1 F = Y10 - Y00 G = DZ0 H = -DZ1 I = Z10 - Z00  # \u0441\u0445\u043b\u043e\u043f\u043d\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 ;) D += A E += B F += C G += A H += B I += C   # \u041f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 def belong0(X, Y, Z):     Q1 = (X - X00) * DY0     Q2 = (Y - Y00) * DX0     Q3 = (Y - Y00) * DZ0     Q4 = (Z - Z00) * DY0     return Q1 == Q2 and Q3 == Q4   # \u041f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 def belong1(X, Y, Z):     Q1 = (X - X10) * DY1     Q2 = (Y - Y10) * DX1     Q3 = (Y - Y10) * DZ1     Q4 = (Z - Z10) * DY1     return Q1 == Q2 and Q3 == Q4   # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 s, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439\/\u043e\u0442\u0440\u0435\u0437\u043a\u0443 def s_to_p(S):     X = X10 + DX1 * S     Y = Y10 + DY1 * S     Z = Z10 + DZ1 * S     print(X, Y, Z)     if belong0(X, Y, Z):         if belong_section(X, Y, Z):             print(\"on section\")             print(X, Y, Z)         else:             print(\"on line, not on section\")             print(X, Y, Z)      else:         print(\"no intersection points, crossing lines\")   # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 t, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439\/\u043e\u0442\u0440\u0435\u0437\u043a\u0443 def t_to_p(T):     X = X00 + DX0 * T     Y = Y00 + DY0 * T     Z = Z00 + DZ0 * T     print(X,Y,Z)     if belong1(X, Y, Z):         if belong_section(X, Y, Z):             print(\"on section\")             print(X, Y, Z)         else:             print(\"on line, not on section\")             print(X, Y, Z)     else:         X = X01 + DX0 * T         Y = Y01 + DY0 * T         Z = Z01 + DZ0 * T         if belong1(X, Y, Z):             if belong_section(X, Y, Z):                 print(\"on section  \")                 print(X, Y, Z)             else:                 print(\"on line, not on section \")                 print(X, Y, Z)         else:             print(\"no intersection points, crossing lines\")   def between(A, B, C):     return A &lt;= B &lt;= C or C &lt;= B &lt;= A   # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u0438\u043b\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043a \u043e\u0442\u0440\u0435\u0437\u043a\u0443 def belong_section(X, Y, Z):     return between(X00, X, X01) and between(Y00, Y, Y01) and between(Z00, Z, Z01)  det =  D*H - E*G if det != 0:     detASS= F*H-I*E     T = detASS\/det     t_to_p(T)  else:     v = DX0 * DX1 + DY0 * DY1 + DZ0 * DZ1     l0 = (DX0**2+DY0**2+DZ0**2)**0.5     l1 = (DX1 ** 2 + DY1 ** 2 + DZ1 ** 2) ** 0.5     cos = v \/ l0 \/ l1     if abs(1-cos) &lt; 0.00000000001:         if belong_section(X10,Y10,Z10):             print(\"same lines\")         else:             print(\"parallel lines\")      else:         print(cos)         print(\"no intersection points\")<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/AndrewTheMaster\/Section-line-and-line-intersections\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a> \u043d\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Python &amp;&amp; turboprolog 2.0<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/770610\/\"> https:\/\/habr.com\/ru\/articles\/770610\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435, \u0434\u043e\u0440\u043e\u0433\u0438\u0435 \u0445\u0430\u0431\u0440\u043e\u0432\u0447\u0430\u043d\u0435, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0432 turboprolog2.0, \u0431\u043e\u043b\u0435\u0435 \u0442\u043e\u0433\u043e \u044f \u043d\u0435 \u043d\u0430\u0448\u0435\u043b \u043d\u0438\u0433\u0434\u0435 \u0433\u043e\u0442\u043e\u0432\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u043d\u0430 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u044b\u0445 \u044f\u0437\u044b\u043a\u0430\u0445 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. <\/p>\n<p>\u0418\u043c\u0435\u0435\u0442\u0441\u044f <a href=\"https:\/\/habr.com\/ru\/articles\/523440\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0435\u0448\u0435\u043d\u0438\u0435<\/a> \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u0434\u0432\u0443\u0445\u043c\u0435\u0440\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430. \u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u0447\u0435\u043c \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u043c\u0443.<\/p>\n<figure class=\"full-width\">\n<div><figcaption>\u041d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u043b\u043e\u0432\u0438\u044f. \u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u0442\u0440\u0435\u0437\u043a\u043e\u043c<\/figcaption><\/div>\n<\/figure>\n<p>\u041f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f \u0437\u0430\u0434\u0430\u043d\u0430 \u0442\u043e\u0447\u043a\u0430\u043c\u0438 P00 \u0438 P01,\u0430 \u0432\u0442\u043e\u0440\u0430\u044f &#8212; \u042010 \u0438 \u042011. \u041a\u0430\u0436\u0434\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0437\u0430\u0434\u0430\u043d\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 X,Y,Z (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, P00 &#8212; X00,Y00,Z00). \u0422\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0442\u043e\u0447\u043a\u0443 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0432\u0430\u044f \u0438\u043c\u0435\u0435\u0442\u0441\u044f. \u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043b\u0438 \u043e\u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u043e\u0442\u0440\u0435\u0437\u043a\u0443 \u0438\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0435\u0433\u043e \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u0438\u0438 (\u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439).<\/p>\n<p>\u0412\u0432\u0435\u0434\u0435\u043c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 DP0 \u0438 DP1, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c \u0438\u043c \u043f\u0440\u044f\u043c\u044b\u043c. \u0412\u044b\u0447\u0438\u0441\u043b\u0438\u043c \u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<pre><code class=\"python\"># \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX0 = X01 - X00 DY0 = Y01 - Y00 DZ0 = Z01 - Z00 # \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX1 = X11 - X10 DY1 = Y11 - Y10 DZ1 = Z11 - Z10<\/code><\/pre>\n<p>\u0422\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u044f\u043c\u044b\u0445 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0438\u0442 \u043e\u0431\u0435\u0438\u043c \u043f\u0440\u044f\u043c\u044b\u043c (\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e?), \u0438 \u0435\u0451 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u0434\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443\u043b\u043e\u0439.<\/p>\n<p>P = P00 + DP0 * t  =  P10 + DP1 * s<\/p>\n<p>\u0420\u0430\u0437\u043b\u043e\u0436\u0438\u043c \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<p>X00 + DX0 * t  =  X10 + DX1 * s<\/p>\n<p>Y00 + DY0 * t  =  Y10 + DY1 * s<\/p>\n<p>Z00 + DZ0 * t  =  Z10 + DZ1 * s<\/p>\n<p>\u0423\u0434\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432 \u0442\u0430\u043a\u043e\u043c \u0432\u0438\u0434\u0435:<\/p>\n<p>DX0 * t  &#8212; DX1 * s = X10 &#8212; X00<\/p>\n<p>DY0 * t  &#8212; DY1 * s = Y10 &#8212; Y00<\/p>\n<p>DZ0 * t  &#8212; DZ1 * s = Z10 &#8212; Z00<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u043c\u0435\u0435\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0442\u043e \u0447\u0435\u0440\u0435\u0437 s \u0438\u043b\u0438 t \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f.<\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0434\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0437\u0430\u043c\u0435\u043d\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0443\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0439 \u043d\u0430 \u043c\u0430\u0442\u0440\u0438\u0446\u0443 \u043a\u043e\u044d\u0444\u0444\u0438\u0446\u0438\u0435\u043d\u0442\u043e\u0432.<\/p>\n<figure class=\"\"><\/figure>\n<p>\u041a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0445\u043b\u043e\u043f\u043d\u0443\u0442\u044c.<\/p>\n<figure class=\"\"><\/figure>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u0432\u0441\u0435 \u0440\u0435\u0448\u0430\u0435\u043c \u0447\u0435\u0440\u0435\u0437 \u041a\u0440\u0430\u043c\u0435\u0440\u0430, \u043f\u0440\u0438\u0432\u043e\u0436\u0443 \u043a\u043e\u0434 \u043a \u0440\u0435\u0448\u0435\u043d\u0438\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043d\u0430 Python.<\/p>\n<pre><code class=\"python\"># \u043f\u0435\u0440\u0432\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f X00 = 0 Y00 = 0 Z00 = 0 X01 = 0 Y01 = 0 Z01 = 5 # \u0432\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u044f\u043c\u0430\u044f X10 = 5 Y10 = 0 Z10 = 0 X11 = 5 Y11 = 0 Z11 = 5  # \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX0 = X01 - X00 DY0 = Y01 - Y00 DZ0 = Z01 - Z00 # \u0432\u0435\u043a\u0442\u043e\u0440 \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 DX1 = X11 - X10 DY1 = Y11 - Y10 DZ1 = Z11 - Z10  # \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u044b A = DX0 B = -DX1 C = X10 - X00 D = DY0 E = -DY1 F = Y10 - Y00 G = DZ0 H = -DZ1 I = Z10 - Z00  # \u0441\u0445\u043b\u043e\u043f\u043d\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 ;) D += A E += B F += C G += A H += B I += C   # \u041f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 def belong0(X, Y, Z):     Q1 = (X - X00) * DY0     Q2 = (Y - Y00) * DX0     Q3 = (Y - Y00) * DZ0     Q4 = (Z - Z00) * DY0     return Q1 == Q2 and Q3 == Q4   # \u041f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439 def belong1(X, Y, Z):     Q1 = (X - X10) * DY1     Q2 = (Y - Y10) * DX1     Q3 = (Y - Y10) * DZ1     Q4 = (Z - Z10) * DY1     return Q1 == Q2 and Q3 == Q4   # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 s, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439\/\u043e\u0442\u0440\u0435\u0437\u043a\u0443 def s_to_p(S):     X = X10 + DX1 * S     Y = Y10 + DY1 * S     Z = Z10 + DZ1 * S     print(X, Y, Z)     if belong0(X, Y, Z):         if belong_section(X, Y, Z):             print(\"on section\")             print(X, Y, Z)         else:             print(\"on line, not on section\")             print(X, Y, Z)      else:         print(\"no intersection points, crossing lines\")   # \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 t, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0442\u043e\u0447\u043a\u0438 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043a \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439\/\u043e\u0442\u0440\u0435\u0437\u043a\u0443 def t_to_p(T):     X = X00 + DX0 * T     Y = Y00 + DY0 * T     Z = Z00 + DZ0 * T     print(X,Y,Z)     if belong1(X, Y, Z):         if belong_section(X, Y, Z):             print(\"on section\")             print(X, Y, Z)         else:             print(\"on line, not on section\")             print(X, Y, Z)     else:         X = X01 + DX0 * T         Y = Y01 + DY0 * T         Z = Z01 + DZ0 * T         if belong1(X, Y, Z):             if belong_section(X, Y, Z):                 print(\"on section  \")                 print(X, Y, Z)             else:                 print(\"on line, not on section \")                 print(X, Y, Z)         else:             print(\"no intersection points, crossing lines\")   def between(A, B, C):     return A &lt;= B &lt;= C or C &lt;= B &lt;= A   # \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043b\u0435\u0436\u0438\u0442 \u043b\u0438 \u0442\u043e\u0447\u043a\u0430 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u043c \u043e\u0442\u0440\u0435\u0437\u043a\u0435 \u0438\u043b\u0438 \u043d\u0430 \u043f\u0435\u0440\u0432\u043e\u0439 \u043f\u0440\u044f\u043c\u043e\u0439, \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438 \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u044c \u043a \u043e\u0442\u0440\u0435\u0437\u043a\u0443 def belong_section(X, Y, Z):     return between(X00, X, X01) and between(Y00, Y, Y01) and between(Z00, Z, Z01)  det =  D*H - E*G if det != 0:     detASS= F*H-I*E     T = detASS\/det     t_to_p(T)  else:     v = DX0 * DX1 + DY0 * DY1 + DZ0 * DZ1     l0 = (DX0**2+DY0**2+DZ0**2)**0.5     l1 = (DX1 ** 2 + DY1 ** 2 + DZ1 ** 2) ** 0.5     cos = v \/ l0 \/ l1     if abs(1-cos) &lt; 0.00000000001:         if belong_section(X10,Y10,Z10):             print(\"same lines\")         else:             print(\"parallel lines\")      else:         print(cos)         print(\"no intersection points\")<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/AndrewTheMaster\/Section-line-and-line-intersections\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430<\/a> \u043d\u0430 \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 Python &amp;&amp; turboprolog 2.0<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/770610\/\"> https:\/\/habr.com\/ru\/articles\/770610\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-358794","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=358794"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/358794\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=358794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=358794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=358794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}