{"id":561,"date":"2017-12-15T22:33:54","date_gmt":"2017-12-15T14:33:54","guid":{"rendered":"http:\/\/www.whudj.cn\/?p=561"},"modified":"2019-06-06T16:57:30","modified_gmt":"2019-06-06T08:57:30","slug":"b-spline%e5%85%ab%e8%8a%82%e7%82%b9%e6%8f%92%e5%85%a5","status":"publish","type":"post","link":"http:\/\/www.whudj.cn\/?p=561","title":{"rendered":"B-Spline(\u516b):\u8282\u70b9\u63d2\u5165"},"content":{"rendered":"<p>\u8282\u70b9\u63d2\u5165\u7684\u542b\u4e49\u662f\u5728\u4e0d\u6539\u53d8\u66f2\u7ebf\u5f62\u72b6\u7684\u524d\u63d0\u4e0b\uff0c\u5411\u8282\u70b9\u5e8f\u5217(knot vector)\u4e2d\u63d2\u5165\u8282\u70b9\u3002\u8282\u70b9\u63d2\u5165\u7684\u51fa\u53d1\u70b9\u4e0eBezier\u66f2\u7ebf\u7684\u5347\u9636\u4e00\u6837\uff0c\u90fd\u662f\u60f3\u589e\u52a0\u63a7\u6307\u70b9\u7684\u6570\u91cf\u4ee5\u589e\u52a0\u66f2\u7ebf\u7684\u81ea\u7531\u5ea6\u3002\u5728\u4e0d\u8003\u8651\u6539\u53d8\u66f2\u7ebf\u9636\u6b21\u7684\u60c5\u51b5\u4e0b\uff0c\u6839\u636e m=p+n+1\u7684\u7b49\u5f0f\uff0c\u8282\u70b9\u6570\u52a0\u4e00\uff0c\u63a7\u5236\u70b9\u6570\u91cf\u52a0\u4e00\u3002<!--more--><\/p>\n<p>\u5047\u8bbe\u6b32\u63d2\u5165\u7684\u8282\u70b9\u4e3au,\u4e14\\(u\\in[u_k,u_{k+1})\\),\u6839\u636eB\u6837\u6761\u7684\u5f3a\u51f8\u5305\u6027\uff0c\\([u_k,u_{k+1})\\)\u6bb5\u66f2\u7ebf\u7531\u63a7\u5236\u70b9\\(P_{k-p},&#8230;,P_k\\)\u63a7\u5236\u3002\u8282\u70b9\u63d2\u5165\u4e5f\u4ec5\u5f71\u54cd\u8fd9\u4e9b\u63a7\u5236\u70b9\u3002\u8282\u70b9\u63d2\u5165\u7684\u65b9\u5f0f\u662f\uff1a\u5728\\(P_kP_{k-1}\\)\u4e0a\u5bfb\u627e\\(Q_k\\)\uff0c\u5728\\(P_{k-1}P_{k-2}\\)\u4e0a\u5bfb\u627e\\(Q_{k-1}\\)\uff0c&#8230;.\uff0c\u5728\\(P_{k-p-1}P_{k-p}\\)\u4e0a\u5bfb\u627e\\(Q_{k-p-1}\\)\u3002\u5373\u5728p+1\u4e2a\u63a7\u5236\u70b9\u6240\u6784\u6210\u7684p\u6761\u8fb9\u4e0a\u627e\u5230p\u4e2a\u70b9\uff0c\u8fde\u540c\u539f\u63a7\u5236\u591a\u8fb9\u5f62\u7684\u9996\u5c3e\\(P_k,P_{k-p}\\)\u5171p+2\u4e2a\u70b9\uff0c\u4ee3\u66ff\u539f\u6765p+1\u4e2a\u63a7\u5236\u70b9\u6784\u6210\u65b0\u66f2\u7ebf\u7684\u63a7\u5236\u70b9\u5e8f\u5217\uff0c\u5176\u4ed6\u63a7\u5236\u70b9\u4e0d\u53d8\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-562 aligncenter\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/knot-insert-1.jpg\" alt=\"\" width=\"240\" height=\"186\" \/><\/p>\n<p>\\(Q_i\\)\u7684\u8ba1\u7b97\u516c\u5f0f\u4e3a\uff1a$$Q_i = (1-\\alpha _i)P_{i-1}+\\alpha _iP_i$$ $$\\alpha_i = \\frac{u-u_i}{u_{i+p}-u_i} ;k-p+1\\le i \\le k$$\u8fd9\u4e2a\u8ba1\u7b97\u6a21\u5f0f\u53ef\u4ee5\u7528\u4e0b\u56fe\u6765\u8868\u793a\uff0c\u63d2\u5165\u8282\u70b9u\u6240\u5f71\u54cd\u7684\u63a7\u5236\u70b9\u5728\u5de6\u5217\uff0c\u63d2\u5165\u540e\u65b0\u8ba1\u7b97\u5f97\u5230\u7684\u63a7\u5236\u70b9\u5217\u5728\u53f3\u8fb9\u3002\u8fde\u7ebf\u8868\u793a\\(Q_i\\)\u662f\u7531\\(P_{i-1}\\),\\(P_i\\)\u7ebf\u6027\u7ec4\u5408\u6784\u6210\u7684\uff0c\u7cfb\u6570\u5206\u522b\u4e3a\\(1-\\alpha_i\\)\u4e0e\\(\\alpha_i\\)\u3002\u8ba1\u7b97\u5b8c\u6210\u540e\uff0c\u7531\u84dd\u8272\u865a\u7ebf\u5708\u51fa\u6765\u7684\u70b9\u4ee3\u66ff\u539f\u6765\u7684\u63a7\u5236\u70b9\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-568 aligncenter\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/knot-in-diag-1.jpg\" alt=\"\" width=\"132\" height=\"287\" \/><\/p>\n<p>\u4e0b\u9762\u770b\u4e00\u4e0b\u8282\u70b9\u63d2\u5165\u7684\u51e0\u4f55\u89e3\u91ca\u3002\\(\\alpha_i:1-\\alpha_i\\)\u662f\u8282\u70b9u\u5c06\u533a\u95f4\\([u_i,u_{i+p})\\)\u5206\u6210\u4e24\u90e8\u5206\u7684\u6bd4\u4f8b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-570\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/knot-insertion-meaning-of-a.jpg\" alt=\"\" width=\"278\" height=\"74\" \/><\/p>\n<p>\u56e0\u6b64\uff0c\u5982\u679c\u6211\u4eec\u628ap\u6b21\u201c\u5207\u89d2\u201d\u7684\\(\\alpha\\)\u90fd\u5806\u8d77\u6765\uff0c\u6548\u679c\u5982\u4e0b\u56fe\u6240\u793a\u3002u\u5bf9\u6bcf\u4e00\u4e2a\u533a\u95f4\\([u_{k-p+1},u_{k+1})\\),\\([u_{k-p+2},u_{k+2})\\),&#8230;,\\([u_{k},u_{k+p})\\)\u5206\u9694\u800c\u6210\u7684\u6bd4\u4f8b\uff0c\u6210\u4e3a\u4e86\u5176\u63a7\u5236\u70b9\u201c\u5207\u89d2\u201d\u7684\u6bd4\u4f8b\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-571\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/knot-insertion-scale-1.jpg\" alt=\"\" width=\"504\" height=\"195\" \/><\/p>\n<p>\u6211\u7684\u63d2\u5165\u8282\u70b9\u7b97\u6cd5\u7684C++\u5b9e\u73b0\u5982\u4e0b:<\/p>\n<pre class=\"lang:c++ decode:true\">void BSpline::InsertKnot(double u)\r\n{\r\n\tstd::vector&lt;double&gt;&amp; knots = m_vecKnots;\r\n\tint p = m_nDegree;\r\n\r\n\t\/\/\u67e5\u627e u \u6240\u5728\u533a\u95f4\r\n\tint k = std::distance(knots.begin(),std::upper_bound(knots.begin(), knots.end(), u))-1;\r\n\tPoint *pArray = new Point[p];\r\n\r\n\t\/\/i \\in [k,k-p+1]\r\n\t\/\/j\u4e3a\u6570\u7ec4pArray\u4f4d\u7f6e\r\n\tfor (int i = k,j=p-1;i&gt;k-p;--i,--j)\r\n\t{\r\n\t\tdouble alpha = (u - knots[i]);\r\n\t\tdouble dev =  (knots[i + p] - knots[i]);\r\n\t\talpha = (dev !=0)? alpha\/dev:0;\r\n\r\n\t\tpArray[j] = m_vecCVs[i - 1] * (1 - alpha) + m_vecCVs[i] * alpha;\r\n\t}\r\n\r\n\t\/\/\u5c06cv [k-p+1,k-1]\u66ff\u6362\u4e3apArray\uff0c\u5e76\u4e14\u5728cv[k]\u4e4b\u524d\u63d2\u5165 pArray[p-1]\r\n\tfor (int i = k - p + 1, j = 0;i &lt; k;++i, ++j)\r\n\t{\r\n\t\tm_vecCVs[i] = pArray[j];\r\n\t}\r\n\tm_vecCVs.insert(m_vecCVs.begin() + k, pArray[p - 1]);\r\n\r\n\t\/\/knots \u63d2\u5165u\r\n\tknots.insert(knots.begin() + k + 1, u);\r\n\r\n\tdelete[] pArray;\r\n}<\/pre>\n<p>\u4e0b\u56fe\u662f\u5bf9\u67d0\u4e003\u9636\u6837\u6761\u66f2\u7ebf\u5728\\(u=3000\\)\u5904\u8fdb\u884c\u4e09\u6b21\u63d2\u503c\u7684\u7ed3\u679c\u5bf9\u6bd4(\u63d2\u503c\u540e\u66f2\u7ebf\u4eba\u4e3a\u79fb\u52a8\u5f00\u65b9\u4fbf\u5c55\u793a)\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-615\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/spline_knot_insertion.png\" alt=\"\" width=\"600\" height=\"322\" \/><\/p>\n<hr \/>\n<p>\u672c\u8282\u53c2\u8003 <a href=\"http:\/\/pages.mtu.edu\/~shene\/COURSES\/cs3621\/NOTES\/spline\/B-spline\/single-insertion.html\">Introduction to Computing with Geometry<\/a> 6.4.1\u8282\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8282\u70b9\u63d2\u5165\u7684\u542b\u4e49\u662f\u5728\u4e0d\u6539\u53d8\u66f2\u7ebf\u5f62\u72b6\u7684\u524d\u63d0\u4e0b\uff0c\u5411\u8282\u70b9\u5e8f\u5217(knot vector)\u4e2d &hellip; <a href=\"http:\/\/www.whudj.cn\/?p=561\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"_links":{"self":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/561"}],"collection":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=561"}],"version-history":[{"count":12,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions"}],"predecessor-version":[{"id":1275,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/561\/revisions\/1275"}],"wp:attachment":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=561"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=561"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}