{"id":254579,"date":"2015-04-06T13:31:06","date_gmt":"2015-04-06T09:31:06","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=254579"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=254579","title":{"rendered":"\u0417\u0430\u043c\u0435\u0442\u043a\u0438 \u043e \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u043c"},"content":{"rendered":"<br \/>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430<\/li>\n<li>\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/li>\n<li>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432<\/li>\n<li>\u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430<\/li>\n<li>\u0420\u044b\u0441\u043a\u0430\u043d\u044c\u0435, \u0442\u0430\u043d\u0433\u0430\u0436, \u043a\u0440\u0435\u043d<\/li>\n<li>\u0421\u0435\u0440\u0438\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/li>\n<\/ul>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430<\/h4>\n<p>  \u0415\u0449\u0451 \u0440\u0430\u0437 \u2013 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%B2%D0%B0%D1%82%D0%B5%D1%80%D0%BD%D0%B8%D0%BE%D0%BD\">\u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/a>? \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u2013 \u044d\u0442\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u2013 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0433\u043e\u043b: <\/p>\n<p>  (w, vx, vy, vz), <\/p>\n<p>  \u0433\u0434\u0435 v \u2013 \u043e\u0441\u044c, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c;<br \/>  w \u2013 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442 (\u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0443\u0433\u043b\u0430).<br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0434\u043e\u043b\u044c \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u0435\u043b\u043a\u0435, \u0435\u0441\u043b\u0438 \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0441 \u043a\u043e\u043d\u0446\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0432 \u0435\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u043e.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0432\u0434\u043e\u043b\u044c \u043e\u0441\u0438 \u0425 \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0432\u043e\u0438\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442: w = 0,7071; x = 0,7071; y = 0; z = 0. \u041b\u0435\u0432\u0430\u044f \u0438\u043b\u0438 \u043f\u0440\u0430\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u0440\u0430\u0437\u043d\u0438\u0446\u044b \u043d\u0435\u0442 \u2013 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u043b\u0438\u0441\u044c \u0432 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442, \u0438\u043b\u0438 \u0432\u0441\u0435 \u0432 \u043b\u0435\u0432\u044b\u0445 \u0438\u043b\u0438 \u0432\u0441\u0435 \u0432 \u043f\u0440\u0430\u0432\u044b\u0445.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/3e4\/055\/32a\/3e405532a06d4695ade71ee48ee151e6.png\"\/><\/p>\n<p>  \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430 (\u043f\u043e\u0434 \u0440\u0443\u0433\u043e\u0439 \u0431\u044b\u043b Visual Basic), \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430 \u0432\u043e\u043a\u0440\u0443\u0433 \u043d\u0435\u0433\u043e:<\/p>\n<pre><code class=\"vbscript\">Public Function create_quat(rotate_vector As TVector, rotate_angle As Double) As TQuat          create_quat.w = Cos(rotate_angle \/ 2)     create_quat.x = rotate_vector.x * Sin(rotate_angle \/ 2)     create_quat.y = rotate_vector.y * Sin(rotate_angle \/ 2)     create_quat.z = rotate_vector.z * Sin(rotate_angle \/ 2)      End Function <\/code><\/pre>\n<p>  \u0412 \u043a\u043e\u0434\u0435 rotate_vector \u2013 \u044d\u0442\u043e \u0432\u0435\u043a\u0442\u043e\u0440, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0441\u044c \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430, \u0430 rotate_angle \u2013 \u044d\u0442\u043e \u0443\u0433\u043e\u043b \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430 \u0432 \u0440\u0430\u0434\u0438\u0430\u043d\u0430\u0445. \u0412\u0435\u043a\u0442\u043e\u0440 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d. \u0422\u043e \u0435\u0441\u0442\u044c \u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0434\u043e\u043b\u0436\u0430 \u0431\u044b\u0442\u044c \u0440\u0430\u0432\u043d\u0430 1.<\/p>\n<pre><code class=\"vbscript\">Public Function normal(v As TVector) As TVector      Dim length As Double      length = (v.x ^ 2 + v.y ^ 2 + v.z ^ 2) ^ 0.5         normal.x = v.x \/ length     normal.y = v.y \/ length     normal.z = v.z \/ length      End Function <\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0434\u043b\u0438\u043d\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c 0. \u0412\u043c\u0435\u0441\u0442\u043e \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0430\u043c \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u044c\u0441\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u044d\u0442\u0443 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e \u0438\u043d\u0434\u0438\u0432\u0438\u0434\u0443\u0430\u043b\u044c\u043d\u043e.<\/p>\n<h4>\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u043c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u043c\u0435\u0442\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442 \u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432. \u041f\u043e\u0434 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u043c \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u043e\u043c \u044f \u0438\u043c\u0435\u044e \u0432\u0432\u0438\u0434\u0443 \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d, \u0442. \u0435. \u0442\u043e\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u043e\u0442 \u0437\u0430\u0434\u0430\u043d\u043d\u043e\u0433\u043e, \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0430\u0437\u0432\u0435\u0440\u043d\u0443\u0442\u044c \u0432\u0435\u043a\u0442\u043e\u0440 \u043e\u0441\u0438 \u0432 \u0434\u0440\u0443\u0433\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443 \u0438 \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d. \u041d\u043e\u0440\u043c\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0432\u0435\u043a\u0442\u043e\u0440\u0430\u0445, \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043a \u0434\u043b\u0438\u043d\u0435 = 1.<\/p>\n<pre><code class=\"vbscript\">Public Function quat_scale(q As TQuat, val As Double) As TQuat      q.w = q.w * val ' x     q.x = q.x * val ' x     q.y = q.y * val ' y     q.z = q.z * val ' z     quat_scale = q  End Function  Public Function quat_length(q As TQuat) As Double      quat_length = (q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z) ^ 0.5  End Function  Public Function quat_normalize(q As TQuat) As TQuat      Dim n As Double     n = quat_length(q)     quat_normalize = quat_scale(q, 1 \/ n)  End Function  Public Function quat_invert(q As TQuat) As TQuat     Dim res As TQuat          res.w = q.w     res.x = -q.x     res.y = -q.y     res.z = -q.z     quat_invert = quat_normalize(res) End Function <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 Y \u043d\u0430 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 = (w=0,707; x = 0; y = 0,707; z=0), \u0442\u043e \u043e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 = (w=0,707; x = 0; y = -0,707; z=0). \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0443 W, \u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430\u0445 \u043d\u0430 180 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u043e\u043d\u0430 = 0. \u041a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u00ab\u043d\u0435\u0442 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430\u00bb = (w=1; x = 0; y = 0; z=0), \u0442\u043e \u0435\u0441\u0442\u044c \u0443 \u043d\u0435\u0433\u043e \u0434\u043b\u0438\u043d\u0430 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043e\u0441\u0438 = 0.<\/p>\n<h4>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432<\/h4>\n<p>  \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432 \u043a\u0440\u0430\u0439\u043d\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u0430\u044f \u0448\u0442\u0443\u043a\u0430. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0443\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 \u0434\u0430\u0451\u0442 \u0442\u0430\u043a\u043e\u0439 \u0436\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0435\u0441\u043b\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u044b \u0443\u043c\u043d\u043e\u0436\u0430\u0435\u043c\u044b\u043c\u0438 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430\u043c\u0438. \u041f\u0440\u0438\u0447\u0451\u043c \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043e\u0442\u0447\u0451\u0442\u0430, \u0442. \u0435. \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043e\u0442\u0447\u0451\u0442\u0430 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u043e\u0433\u043e \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u0432\u0438\u0433\u0430\u0435\u0442\u0441\u044f.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/6db\/f82\/2e4\/6dbf822e4d1d472ebee922885e0345f5.png\"\/> <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/538\/a94\/cec\/538a94cec0814c2eb5f6b4622074db56.png\"\/><\/p>\n<p>  \u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<pre><code class=\"vbscript\">Public Function quat_mul_quat(a As TQuat, b As TQuat) As TQuat      Dim res As TQuat     res.w = a.w * b.w - a.x * b.x - a.y * b.y - a.z * b.z     res.x = a.w * b.x + a.x * b.w + a.y * b.z - a.z * b.y     res.y = a.w * b.y - a.x * b.z + a.y * b.w + a.z * b.x     res.z = a.w * b.z + a.x * b.y - a.y * b.x + a.z * b.w     quat_mul_quat = res  End Function <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u043d\u0430 3D \u0432\u0435\u043a\u0442\u043e\u0440, \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u043a\u0442\u043e\u0440 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 W = 0 \u0438 \u0443\u043c\u043d\u043e\u0436\u0438\u0442\u044c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d \u043d\u0430 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d. \u0418\u043b\u0438 \u043f\u043e\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u043e\u043b\u044c \u0438 \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u044d\u0442\u043e \u0432 \u0432\u0438\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"vbscript\">Public Function quat_mul_vector(a As TQuat, b As TVector) As TQuat          Dim res As TQuat     res.w = -a.x * b.x - a.y * b.y - a.z * b.z     res.x = a.w * b.x + a.y * b.z - a.z * b.y     res.y = a.w * b.y - a.x * b.z + a.z * b.x     res.z = a.w * b.z + a.x * b.y - a.y * b.x     quat_mul_vector = res      End Function <\/code><\/pre>\n<p>  <\/p>\n<h4>\u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430<\/h4>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u043c:<\/p>\n<pre><code class=\"vbscript\">Public Function quat_transform_vector(q As TQuat, v As TVector) As TVector          Dim t As TQuat          t = quat_mul_vector(q, v)     t = quat_mul_quat(t, quat_invert(q))          quat_transform_vector.x = t.x     quat_transform_vector.y = t.y     quat_transform_vector.z = t.z      End Function <\/code><\/pre>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440: <\/p>\n<p>  \u0412\u0435\u043a\u0442\u043e\u0440 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u043e\u0441\u044c (x=1; y=0; z=1). \u0423\u0433\u043e\u043b \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0430 180 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432.<br \/>  \u041f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 (x=0; y=0; z=1). \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0440\u0430\u0432\u0435\u043d (x=1; y=0; z=0).<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/c75\/b1f\/603\/c75b1f6036464084b32c98f50d990d00.png\"\/><\/p>\n<h4>\u0420\u044b\u0441\u043a\u0430\u043d\u044c\u0435, \u0442\u0430\u043d\u0433\u0430\u0436, \u043a\u0440\u0435\u043d<\/h4>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043e\u0441\u0435\u0439:<br \/>  \u0420\u044b\u0441\u043a\u0430\u043d\u044c\u0435 = heading = yaw = \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 Z; \u0442\u0430\u043d\u0433\u0430\u0436 = altitude = pitch = \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 Y; \u043a\u0440\u0435\u043d = bank = roll = \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 X.<\/p>\n<pre><code class=\"vbscript\">    yaw = angles.altitude     pitch = angles.bank     roll = angles.heading          hr = roll * 0.5     shr = Sin(hr)     chr = Cos(hr)     hp = pitch * 0.5     shp = Sin(hp)     chp = Cos(hp)     hy = yaw * 0.5     shy = Sin(hy)     chy = Cos(hy)     chy_shp = chy * shp     shy_chp = shy * chp     chy_chp = chy * chp     shy_shp = shy * shp          res.w = (chy_chp * chr) + (shy_shp * shr)      res.x = (chy_shp * chr) + (shy_chp * shr)      res.y = (shy_chp * chr) - (chy_shp * shr)      res.z = (chy_chp * shr) - (shy_shp * chr)           quat_from_angles_rad = res <\/code><\/pre>\n<p>  \u0418 \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443, \u0438\u0437 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430:<\/p>\n<pre><code class=\"vbscript\">    k.bank = atan2(2 * (w * x + y * z), 1 - 2 * (sqx + sqy))     k.altitude = Application.WorksheetFunction.Asin(2 * (w * y - x * z))     k.heading = atan2(2 * (w * z + x * y), 1 - 2 * (sqy + sqz)) <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0421\u0435\u0440\u0438\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/h4>\n<p>  \u0420\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440:<br \/>  1. \u041f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u2013 \u0440\u044b\u0441\u043a\u0430\u043d\u044c\u0435 (\u0432\u043e\u043a\u0440\u0443\u0433 Z) 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439;<br \/>  2. \u0412\u0442\u043e\u0440\u043e\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u2013 \u0442\u0430\u043d\u0433\u0430\u0436 (\u0432\u043e\u043a\u0440\u0443\u0433 Y) 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439;<br \/>  3. \u0422\u0440\u0435\u0442\u0438\u0439 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u2013 \u043a\u0440\u0435\u043d (\u0432\u043e\u043a\u0440\u0443\u0433 X) 90 \u0433\u0440\u0430\u0434\u0443\u0441\u043e\u0432 \u043f\u043e \u0447\u0430\u0441\u043e\u0432\u043e\u0439.<\/p>\n<p>  \u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u0435 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u00abglobal\u00bb \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u044b \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u044b\u0445 \u043e\u0441\u0435\u0439 XYZ. \u0422\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c, \u0435\u0441\u043b\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u044b \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u0442, \u0433\u0434\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0432\u0435\u043a\u0442\u043e\u0440, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0443 \u043d\u0435\u0433\u043e \u0431\u044b\u043b\u0438 X=1; Y=0; Z=0.<\/p>\n<p>  \u0420\u0438\u0441\u0443\u043d\u043a\u0438, \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043a\u0430\u043a \u00ablocal\u00bb \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043e\u0441\u0435\u0439 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0441\u0430\u043c\u043e\u043b\u0435\u0442\u043e\u043c. \u0422\u043e \u0435\u0441\u0442\u044c \u0432\u0441\u0435 \u0432\u0440\u0430\u0449\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0438\u043b\u043e\u0442\u0430, \u0430 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0435\u043f\u043e\u0434\u0432\u0438\u0436\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442. \u0427\u0435\u0442\u0432\u0451\u0440\u0442\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0433\u0434\u0435 \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u0442\u043e\u0442 \u0436\u0435 \u0441\u0430\u043c\u044b\u0439 \u0432\u0435\u043a\u0442\u043e\u0440 (1; 0; 0) \u0432 \u0438\u0442\u043e\u0433\u0435 \u0432\u0441\u0435\u0445 \u0442\u0440\u0451\u0445 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432. \u0422\u0430\u043a\u043e\u0439 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c, \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0432 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u044b \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d.<\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/016\/307\/2a3\/0163072a38164ee5821310b871ca1d02.png\"\/> <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/afc\/59d\/683\/afc59d683feb4efba314b81f3e72a492.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/e5f\/ef0\/a64\/e5fef0a644d6433b8334e1e3c7f804fd.png\"\/> <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/a0f\/dce\/e8c\/a0fdcee8ce074188b629a4e7ba7a6386.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/085\/cc2\/a97\/085cc2a97dc745aa893700b61822af40.png\"\/> <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/997\/849\/1e8\/9978491e80ac4e15a25e1dd98215038e.png\"\/><\/p>\n<p>  <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/bd1\/278\/001\/bd1278001084462aaf553ab7be6d3d71.png\"\/> <img decoding=\"async\" src=\"\/\/habrastorage.org\/files\/abf\/c5c\/9ac\/abfc5c9ac38946babd5308982d4ed048.png\"\/> \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/255005\/\"> http:\/\/habrahabr.ru\/post\/255005\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<br \/>\n<h4>\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0443\u0431\u043b\u0438\u043a\u0430\u0446\u0438\u0438<\/h4>\n<p>  <\/p>\n<ul>\n<li>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430<\/li>\n<li>\u041e\u0431\u0440\u0430\u0442\u043d\u044b\u0439 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/li>\n<li>\u0423\u043c\u043d\u043e\u0436\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u043e\u0432<\/li>\n<li>\u041f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u0435\u043a\u0442\u043e\u0440\u0430<\/li>\n<li>\u0420\u044b\u0441\u043a\u0430\u043d\u044c\u0435, \u0442\u0430\u043d\u0433\u0430\u0436, \u043a\u0440\u0435\u043d<\/li>\n<li>\u0421\u0435\u0440\u0438\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432<\/li>\n<\/ul>\n<h4>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d\u0430 \u0438\u0437 \u0432\u0435\u043a\u0442\u043e\u0440\u0430 \u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u0443\u0433\u043b\u0430 \u0440\u0430\u0437\u0432\u043e\u0440\u043e\u0442\u0430<\/h4>\n<p>  \u0415\u0449\u0451 \u0440\u0430\u0437 \u2013 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D0%B2%D0%B0%D1%82%D0%B5%D1%80%D0%BD%D0%B8%D0%BE%D0%BD\">\u043a\u0432\u0430\u0442\u0435\u0440\u043d\u0438\u043e\u043d<\/a>? \u0414\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u2013 \u044d\u0442\u043e \u043f\u0440\u0435\u0436\u0434\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0438\u0439 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u2013 \u043f\u043e\u0432\u043e\u0440\u043e\u0442 \u0432\u043e\u043a\u0440\u0443\u0433 \u043e\u0441\u0438 \u043d\u0430 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u0439 \u0443\u0433\u043e\u043b: <\/p>\n<p>  (w, vx, vy, vz), <\/p>\n<p>  \u0433\u0434\u0435 v \u2013 \u043e\u0441\u044c, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u043a\u0442\u043e\u0440\u043e\u043c;<br \/>  w \u2013 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0449\u0430\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442 (\u043a\u043e\u0441\u0438\u043d\u0443\u0441 \u043f\u043e\u043b\u043e\u0432\u0438\u043d\u044b \u0443\u0433\u043b\u0430).  <\/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-254579","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/254579","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=254579"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/254579\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=254579"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=254579"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=254579"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}