{"id":14936,"date":"2022-04-26T20:56:36","date_gmt":"2022-04-26T12:56:36","guid":{"rendered":"https:\/\/www.bookcard.net\/wordpress\/?p=14936"},"modified":"2022-08-14T23:32:16","modified_gmt":"2022-08-14T15:32:16","slug":"arc2d","status":"publish","type":"post","link":"https:\/\/www.bookcard.net\/wordpress\/arc2d\/","title":{"rendered":"\u6e38\u6232\u8f35-\u5f27\u5f62\u78b0\u649e"},"content":{"rendered":"<figure id=\"attachment_14937\" aria-describedby=\"caption-attachment-14937\" style=\"width: 1280px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/04\/ARC2D.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-14937\" src=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/04\/ARC2D.jpg\" alt=\"\u6e38\u6232\u8f35-\u5f27\u5f62\u78b0\u649e\" width=\"1280\" height=\"800\" srcset=\"https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/04\/ARC2D.jpg 1280w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/04\/ARC2D-300x188.jpg 300w, https:\/\/www.bookcard.net\/wordpress\/wp-content\/uploads\/2022\/04\/ARC2D-768x480.jpg 768w\" sizes=\"auto, (max-width: 1280px) 100vw, 1280px\" \/><\/a><figcaption id=\"caption-attachment-14937\" class=\"wp-caption-text\">\u6e38\u6232\u8f35-\u5f27\u5f62\u78b0\u649e<\/figcaption><\/figure>\n<p>\u4e8b\u56e0\u300e\u98a8\u6c34\u7f85\u76e4\u300f\u7531\u5f27\u6247\u5f62\u57fa\u5ea7\u7d44\u6210. \u8981\u958b\u767c\u5f27\u6247\u5f62\u78b0\u649e\u6280\u8853.<\/p>\n<p>\u5148\u5b9a\u7fa9\u5f27\u6247\u7d50\u6784, \u300e\u89d2\u5ea6\u300f\u300e\u5f27\u5ea6\u300f\u4fc2\u786c\u5e63\u4e24\u9762, \u4fc2\u76f8, \u53ef\u76f8\u4e92\u8f49\u63db\u63db<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"575\">\u89d2\u5ea6 = \u5f27\u5ea6 * 180.0\/PI<\/td>\n<\/tr>\n<tr>\n<td width=\"575\">\u5f27\u5ea6= \u89d2\u5ea6 * PI\/180.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5f27\u6247\u5f62\u57fa\u5ea7\u6709\u4e24\u300e\u5f27\u5ea6\u300f\u76f8\u7b49\u5f27\u5f62, \u79bb\u4e2d\u9ede\u8ddd\u79bb\u5514\u540c, \u9060\u79bb\u4e2d\u9ede\u5f27.\u8f03\u57cb\u4e2d\u9ede\u5f27,<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"288\">typedef struct ARC2D_TYP {<\/td>\n<td width=\"288\">\u5f27\u6247\u7d50\u6784<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">VECTOR2D center;<\/td>\n<td width=\"288\">\u4e2d\u5fc3\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">float angle;<\/td>\n<td width=\"288\">\u89d2\u5ea6<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">float rotate;<\/td>\n<td width=\"288\">\u8f49\u65cb<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">float far;<\/td>\n<td width=\"288\">\u6700\u8fdc\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">float near;<\/td>\n<td width=\"288\">\u6700\u8fd1\u9ede<\/td>\n<\/tr>\n<tr>\n<td width=\"288\">}ARC2D, *ARC2D_PTR;<\/td>\n<td width=\"288\">&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9996\u8981\u5224\u65ad\u547d\u4e2d\u3e03\u662f\u54aa\u4fc2\u300e\u6700\u8fdc\u9ede\u300f\u300e\u6700\u8fd1\u9ede\u300f\u4e4b\u9593.<\/p>\n<p>\u547d\u4e2d\u3e03<\/p>\n<p>Init_VECTOR2D(&amp;va,x,y);<\/p>\n<p>\u8a08\u89f8\u6478\u3e03\u540c\u5f27\u4e2d\u5fc3\u3e03\u8ddd\u96e2<\/p>\n<p>Sub_VECTOR2D(&amp;vdiff, &amp;arc-&gt;center, &amp;va);<\/p>\n<p>\u8a08\u5411\u91cf\u9577\u5ea6<\/p>\n<p>float length = Length_VECTOR2D(&amp;vdiff);<\/p>\n<p>\u5224\u65ad\u547d\u4e2d\u5f27\u7dda\u4e4b\u9593<\/p>\n<p>if(length &lt; arc-&gt;near || length &gt; arc-&gt;far )<\/p>\n<p>return false;<\/p>\n<p>\u8a08\u843d\u9ede\u4f4d\u65bc\u5f27\u6247\u5939\u89d2\u4e4b\u9593. \u5f27\u6247\u5939\u4e24\u908a\u9577\u58f9\u81f4. \u5373\u7b49\u908a\u4e09\u89d2\u5f62, \u8996\u540c\u4e24\u76f4\u89d2\u4e09\u89d2\u5f62.<\/p>\n<table>\n<tbody>\n<tr>\n<td width=\"298\">sin(a)= \u5c0d\u908a\/\u659c\u908a.<\/td>\n<td width=\"277\">&nbsp;<\/td>\n<\/tr>\n<tr>\n<td width=\"298\">a= asinf (\u5c0d\u908a\/\u659c\u908a)<\/td>\n<td width=\"277\">asinf(\u5f27\u5ea6)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8a08\u5f27\u6247\u908a\u9577<\/p>\n<p>Copy_VECTOR2D(&amp;va,&amp;vdiff);<\/p>\n<p>Init_VECTOR2D(&amp;vb,0,length);<\/p>\n<p>Sub_VECTOR2D(&amp;vdiff, &amp;va, &amp;vb);<\/p>\n<p>cEdge = Length_VECTOR2D(&amp;vdiff);<\/p>\n<p>\u8a08va\u548cvb\u4e4b\u95f4\u7684\u5939\u89d2<\/p>\n<p>cAngle = RAD_TO_DEG( asinf((cEdge \/ 2) \/ bEdge) ) * 2;<\/p>\n<p>\u5224\u65ad\u547d\u4e2d\u5f27\u5f62\u5939\u89d2\u4e4b\u9593<\/p>\n<p>begin = (-arc-&gt;angle\/2) + arc-&gt;rotate ;<\/p>\n<p>end\u00a0\u00a0 = (arc-&gt;angle\/2) + arc-&gt;rotate ;<\/p>\n<p>return Compute_Angle_In_RAC(cAngle, begin, end); \/\/ \u5939\u89d2\u843d\u3e03<\/p>\n<p>&nbsp;<\/p>\n<p>\u5224\u65ad\u9802\u662f\u54aa\u4fc2\u5f27\u5167<\/p>\n<p>bool Compute_Angle_In_RAC(float angle,float begin,float end){<\/p>\n<p>float offset;<\/p>\n<p>angle = Format_Angle(angle);\/\/\u683c\u5f0f\u89d2<\/p>\n<p>begin = Format_Angle(begin);\/\/\u683c\u5f0f\u89d2<\/p>\n<p>end = Format_Angle(end);\/\/\u683c\u5f0f\u89d2<\/p>\n<p>if(_begin &gt; _end){<\/p>\n<p>_end\u00a0\u00a0 = _end + 360;<\/p>\n<p>if(_angle &gt; 0 &amp;&amp; _angle &lt; end )<\/p>\n<p>_angle = _angle + 360;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>if( _angle &gt;= _begin &amp;&amp; _angle &lt;= _end )\/\/ \u5939\u89d2\u843d\u3e03<\/p>\n<p>return true; return false;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>\u6b78\u58f9\u89d2\/\u683c\u5f0f\u89d2<\/p>\n<p>float Format_Angle(float angle){<\/p>\n<p>if(angle &lt; 0)<\/p>\n<p>angle = angle + 360;<\/p>\n<p>else<\/p>\n<p>if(angle &gt;= 360)<\/p>\n<p>angle = angle &#8211; 360;<\/p>\n<p>return angle;<\/p>\n<p>}<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e8b\u56e0\u300e\u98a8\u6c34\u7f85\u76e4\u300f\u7531\u5f27\u6247\u5f62\u57fa\u5ea7\u7d44\u6210. \u8981\u958b\u767c\u5f27\u6247\u5f62\u78b0\u649e\u6280\u8853. \u5148\u5b9a\u7fa9\u5f27\u6247\u7d50\u6784, \u300e\u89d2\u5ea6\u300f\u300e\u5f27\u5ea6\u300f\u4fc2\u786c\u5e63\u4e24\u9762, \u4fc2 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.bookcard.net\/wordpress\/arc2d\/\" class=\"more-link\">\u7e7c\u7e8c\u95b1\u8b80 <span class=\"screen-reader-text\">\u6e38\u6232\u8f35-\u5f27\u5f62\u78b0\u649e<\/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":[10,42],"class_list":["post-14936","post","type-post","status-publish","format-standard","hentry","category-algorithm","category-pc","tag-algorithm","tag-computer","entry"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14936","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=14936"}],"version-history":[{"count":4,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14936\/revisions"}],"predecessor-version":[{"id":15154,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/posts\/14936\/revisions\/15154"}],"wp:attachment":[{"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/media?parent=14936"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/categories?post=14936"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bookcard.net\/wordpress\/wp-json\/wp\/v2\/tags?post=14936"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}