{"id":4169,"date":"2018-06-21T07:15:11","date_gmt":"2018-06-20T23:15:11","guid":{"rendered":"http:\/\/www.bookcard.net\/wordpress\/?p=4169"},"modified":"2018-06-21T07:16:52","modified_gmt":"2018-06-20T23:16:52","slug":"game_model_aabb","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/game_model_aabb\/","title":{"rendered":"\u904a\u6232\u5efa\u6a21\u4e4b\u908a\u754c\u76d2"},"content":{"rendered":"<figure id=\"attachment_4170\" aria-describedby=\"caption-attachment-4170\" style=\"width: 1024px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/GAME_MODEL_AABB.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-4170\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/GAME_MODEL_AABB.jpg\" alt=\"\" width=\"1024\" height=\"768\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/GAME_MODEL_AABB.jpg 1024w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/GAME_MODEL_AABB-300x225.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2018\/06\/GAME_MODEL_AABB-768x576.jpg 768w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption id=\"caption-attachment-4170\" class=\"wp-caption-text\">\u904a\u6232\u5efa\u6a21\u4e4b\u908a\u754c\u76d2<\/figcaption><\/figure>\n<p>\u300e<a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_sphere\/\">\u908a\u754c\u7403<\/a>\u300f\u96d6\u7136\u53ef\u89e3\u537b\u5927\u90e83D\u6a21\u578b\u300e\u78b0\u649e\u6e2c\u8a66\u300f\u554f\u984c.\u55ae\u82e53D\u6a21\u578b\u662f\u9577\u689d\u5f62\u5247\u4e0d\u9069\u5408\u5982\u300e\u7246\u9ad4\u300f\u300e\u9577\u528d\u300f.\u300e\u8ef8\u5c0d\u9f4a\u5750\u6a19\u908a\u754c\u76d2\u300faxis-aligned bounding box(AABB)\u5f15\u5165\u5247\u53ef\u89e3\u6c7a\u9019\u985e\u554f\u984c.\u6bcf\u500b\u300e\u908a\u754c\u76d2\u300f\u5747\u75313D\u6a21\u578b\u300e\u4e2d\u5fc3\u9ede\u300f\u8207\u300e\u6700\u9060\u9ede\u300f\u3001\u300e\u6700\u8fd1\u9ede\u300f\u6240\u7d44\u6210.\u901a\u904e\u904d\u6b77\u6bcf\u500b3D\u6a21\u578b\u9802\u9ede\u627e\u51faXYZ\u4e09\u8ef8\u4e0a\u6700\u9060\u9802\u9ede.\u5b9a\u7fa93D\u908a\u754c\u76d2:<\/p>\n<p>typedef struct AABB_TYP {<\/p>\n<p>VECTOR3D center;\/\/ \u4e2d\u5fc3\u9ede<\/p>\n<p>VECTOR3D far;\/\/ \u6700\u9060<\/p>\n<p>VECTOR3D near;\/\/ \u6700\u8fd1<\/p>\n<p>}AABB, *AABB_PTR;<\/p>\n<p>&nbsp;<\/p>\n<p>\u300e3D\u6a21\u578b\u300f\u6700\u9060\u9ede\u8207\u6700\u8fd1\u9ede\u53ef\u904d\u6b77\u6240\u67093D\u6a21\u578b\u9802\u9ede\u7372\u5f97:<\/p>\n<p>1.\u6700\u9060\u9ede\u8207\u6700\u8fd1\u9ede\u6e05\u96f6<\/p>\n<p>VECTOR3D far = {0,0,0};\/\/ \u6700\u9060\u9ede<\/p>\n<p>VECTOR3D near = {0,0,0};\/\/ \u6700\u8fd1\u9ede<\/p>\n<p>2.\u904d\u6b77\u6240\u67093D\u9802\u9ede<\/p>\n<p>for (int index = 0; index &lt; vertex_num; ++index){<\/p>\n<p>3.XYZ\u4e09\u8ef8\u6700\u9060\u9ede<\/p>\n<p>if (far.x &gt; vertex_array[index].x)<\/p>\n<p>vertex_array[index].x = far.x;<\/p>\n<p>if (far.y &gt; vertex_array[index].y)<\/p>\n<p>vertex_array[index].y = far.y;<\/p>\n<p>if (far.z &gt; vertex_array[index].z)<\/p>\n<p>vertex_array[index].z = far.z;<\/p>\n<p>4.XYZ\u4e09\u8ef8\u6700\u8fd1\u9ede<\/p>\n<p>if (near.x &gt; vertex_array[index].x)<\/p>\n<p>vertex_array[index].x = near.x;<\/p>\n<p>if (near.y &gt; vertex_array[index].y)<\/p>\n<p>vertex_array[index].y = near.y;<\/p>\n<p>if (near.z &gt; vertex_array[index].z)<\/p>\n<p>vertex_array[index].z = near.z;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\u5224\u65b7\u9802\u9ede\u662f\u5426\u70ba\u65bc\u908a\u754c\u76d2<\/p>\n<p>bool Compute_Point_In_AABB(AABB_PTR aabb, VECTOR3D_PTR point)<\/p>\n<p>{<\/p>\n<p>if ((point-&gt;x &gt;= aabb-&gt;center.x + aabb-&gt;near.x &amp;&amp; point-&gt;x &lt;= aabb-&gt;center.x + aabb-&gt;far.x) &amp;&amp;<\/p>\n<p>(point-&gt;y &gt;= aabb-&gt;center.y + aabb-&gt;near.y &amp;&amp; point-&gt;y &lt;= aabb-&gt;center.y + aabb-&gt;far.y) &amp;&amp;<\/p>\n<p>(point-&gt;z &gt;= aabb-&gt;center.z + aabb-&gt;near.z &amp;&amp; point-&gt;z &lt;= aabb-&gt;center.z + aabb-&gt;far.z) )<\/p>\n<p>return true;<\/p>\n<p>return false;<\/p>\n<p>}<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u300e\u908a\u754c\u7403\u300f\u96d6\u7136\u53ef\u89e3\u537b\u5927\u90e83D\u6a21\u578b\u300e\u78b0\u649e\u6e2c\u8a66\u300f\u554f\u984c.\u55ae\u82e53D\u6a21\u578b\u662f\u9577\u689d\u5f62\u5247\u4e0d\u9069\u5408\u5982\u300e\u7246\u9ad4\u300f\u300e\u9577\u528d\u300f.\u300e\u8ef8\u5c0d\u9f4a\u5750\u6a19 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/game_model_aabb\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">\u904a\u6232\u5efa\u6a21\u4e4b\u908a\u754c\u76d2<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,13],"tags":[41,42],"class_list":["post-4169","post","type-post","status-publish","format-standard","hentry","category-algorithm","category-pc","tag-science","tag-computer","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4169","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/comments?post=4169"}],"version-history":[{"count":3,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4169\/revisions"}],"predecessor-version":[{"id":4173,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/4169\/revisions\/4173"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=4169"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=4169"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=4169"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}