{"id":672,"date":"2017-12-26T18:57:47","date_gmt":"2017-12-26T10:57:47","guid":{"rendered":"http:\/\/www.whudj.cn\/?p=672"},"modified":"2017-12-26T18:58:44","modified_gmt":"2017-12-26T10:58:44","slug":"b-spline11%e6%a0%b7%e6%9d%a1%e6%9b%b2%e7%ba%bf%e6%8b%9f%e5%90%88-%e5%85%89%e9%a1%ba%e9%80%bc%e8%bf%91","status":"publish","type":"post","link":"http:\/\/www.whudj.cn\/?p=672","title":{"rendered":"B-Spline(11):\u6837\u6761\u66f2\u7ebf\u62df\u5408-\u5149\u987a\u903c\u8fd1"},"content":{"rendered":"<p>\u66f2\u7ebf\u62df\u5408\u5305\u542b\u4e24\u4e2a\u65b9\u9762\uff0c\u63d2\u503c(interpolation)\u548c\u903c\u8fd1(approximation)\u3002\u7528\u4e8e\u66f2\u7ebf\u62df\u5408\u7684\u79bb\u6563\u70b9\u901a\u5e38\u4e0d\u5177\u6709\u975e\u5e38\u9ad8\u7684\u7cbe\u5ea6\uff0c\u76f4\u63a5\u63d2\u503c\u5f97\u5230\u7684\u66f2\u7ebf\u53ef\u80fd\u4e0d\u6ee1\u8db3\u201c\u5149\u987a(fair)\u201d\u8981\u6c42,\u672c\u8282\u7684\u76ee\u6807\u662f\u4ecb\u7ecd\u5149\u987a\u7684\u5b9a\u4e49\uff0c\u4ee5\u53ca\u7ed9\u51fa\u4e00\u79cd\u6ee1\u8db3\u201c\u5149\u987a\u201d\u8981\u6c42\u7684\u6700\u5c0f\u4e8c\u4e58\u903c\u8fd1\u65b9\u6cd5\u3002<!--more--><\/p>\n<p>1\uff09\u5149\u987a\u7684\u5b9a\u4e49<\/p>\n<p>\u66f2\u7ebf\u5149\u987a\u5176\u5b9e\u662fNURBS\u66f2\u7ebf\u7814\u7a76\u7684\u4e00\u652f\u975e\u5e38\u91cd\u8981\u7684\u5206\u652f\uff0c\u4f5c\u4e3a\u4e00\u4e2a\u975e\u6570\u5b66\u4e13\u4e1a\u7684\u5b66\u751f\uff0c\u6211\u4eec\u4e0d\u80fd\u5b8c\u5168\u7ed9\u51fa\u975e\u5e38\u4e25\u8c28\u7684\u6570\u5b66\u5b9a\u4e49\uff0c\u4ec5\u80fd\u4ece\u5e94\u7528\u65b9\u9762\u4ecb\u7ecd\u5149\u987a\u7684\u610f\u4e49\u53ca\u5e94\u7528\u3002\u9996\u5148\uff0c\u6211\u5df2\u7ecf\u4ecb\u7ecd\u4e86\u66f2\u7ebf\u7684\u63d2\u503c\u662f\u4ee4\u6837\u6761\u66f2\u7ebf\u4e25\u683c\u7684\u7a7f\u8fc7\u6240\u6709\u7684\u578b\u503c\u70b9(Fit Point)\uff0c\u8fd9\u6837\u6c42\u51fa\u6765\u7684\u66f2\u7ebf\uff0c\u56e0\u4e3a\u7ed9\u5b9a\u70b9\u7684\u7cbe\u5ea6\u95ee\u9898\uff0c\u901a\u5e38\u5177\u6709\u66f2\u7387\u53d8\u5316\u5e45\u5ea6\u7279\u522b\u5927\u7684\u95ee\u9898\u3002\u6bd4\u5982\u4e0b\u56fe\uff0c\u865a\u7ebf\u8868\u793a\u79cb\u66f2\u7ebf\u7684\u201c\u66f2\u7387\u4f34\u968f\u66f2\u7ebf\u201d\uff0c\u53ef\u4ee5\u770b\u5230\uff0c\u66f2\u7ebf\u7684\u66f2\u7387\u53d8\u5316\u662f\u975e\u5e38\u5267\u70c8\u7684\uff08\u4f46\u662f\uff0c\u66f2\u7ebf\u7684\u66f2\u7387\u4ecd\u7136\u662f\u8fde\u7eed\u7684\uff0c\u4e0d\u8981\u6df7\u6dc6\uff09\uff0c\u8fd9\u79cd\u73b0\u8c61\uff0c\u79f0\u4e4b\u4e3a\u66f2\u7ebf\u4e0d\u5149\u987a\u3002<\/p>\n<p><div id=\"attachment_673\" style=\"width: 410px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-673\" class=\"wp-image-673 size-full\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/unfair_curve.png\" alt=\"\" width=\"400\" height=\"533\" \/><p id=\"caption-attachment-673\" class=\"wp-caption-text\">Poliakoff J F, Wong Y K, Thomas P D. An automated curve fairing algorithm for cubic B -spline curves[J]. Journal of Computational &amp; Applied Mathematics, 1999, 102(1):73-85.<\/p><\/div>\u4e3a\u4ec0\u4e48\u4f1a\u4ea7\u751f\u8fd9\u6837\u7684\u95ee\u9898\u5462\uff1f\u53ef\u4ee5\u7528\u4e0b\u56fe\u89e3\u91ca\uff0c\u5047\u8bbe\u7406\u60f3\u7684\u66f2\u7ebf\u5e94\u8be5\u662f\u5706(\u7070\u8272)\uff0c\u4f46\u662f\u4e2d\u95f4\u7684\u9ed1\u70b9\u5b58\u5728\u504f\u5dee\u7684\u60c5\u51b5\u4e0b\uff0c\u66f2\u7ebf\u5bf9\u5e94\u7684\u90e8\u5206\u4f1a\u6709\u4e00\u4e2a<span style=\"text-decoration: underline;\">\u4e0d\u5fc5\u8981<\/span>\u7684\u201c\u5f2f\u6298\u201d\uff0c\u8868\u73b0\u5728\u66f2\u7387\u4e0a\uff0c\u4f1a\u51fa\u73b0\u8fd9\u90e8\u5206\u66f2\u7387\u5267\u70c8\u53d8\u5927\u7684\u60c5\u51b5\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-674\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/cause_of_unfairing_curve.png\" alt=\"\" width=\"300\" height=\"134\" \/><\/p>\n<p>\u5047\u8bbe\u6837\u6761\u66f2\u7ebf\u662f\u4e00\u6761\u94a2\u4e1d\uff08\u5c31\u50cf\u6700\u65e9\u7684\u9020\u8239\u4e1a\u4f7f\u7528\u7684\u6837\u6761\u4e00\u6837\uff09\uff0c\u88ab\u4e0a\u9762\u7684\u56db\u4e2a\u9ed1\u8272\u7684\u201cduck\u201d\u7ea6\u675f\uff0c\u4e2d\u95f4\u7684\u9ed1\u70b9\u90e8\u5206\u5c31\u4ea7\u751f\u4e86\u591a\u4f59\u7684\u5f39\u6027\u52bf\u80fd\uff0c\u56e0\u6b64\uff0c\u5e7f\u6cdb\u7684\u66f2\u7ebf\u201c\u5149\u987a\u201d\u7684\u5b9a\u4e49\u5c31\u662f\u66f2\u7ebf\u4e0a\u6ca1\u6709\u591a\u4f59\u7684\u201c\u80fd\u91cf\u201d\u3002<\/p>\n<p>2\uff09\u66f2\u7ebf\u6700\u5c0f\u4e8c\u4e58\u62df\u5408\u7684\u4e00\u822c\u5f62\u5f0f<\/p>\n<p>\u56e0\u4e3a\u66f2\u7ebf\u5149\u987a\u4f18\u5316\u662fNURBS\u7684\u4e00\u4e2a\u91cd\u8981\u7684\u7814\u7a76\u5206\u652f\uff08\u81f3\u4eca\u4ecd\u7136\u6d3b\u8dc3\uff09\uff0c\u56e0\u6b64\u5149\u987a\u7b97\u6cd5\u4e5f\u4e0d\u4e00\u800c\u8db3\u3002\u5176\u4e2d\uff0c\u5e7f\u6cdb\u5e94\u7528\u7684\u4e00\u79cd\u7ebf\u6027\u6700\u5c0f\u4e8c\u4e58\u62df\u5408\u7684\u65b9\u5f0f\u4e00\u822c\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p>\u6700\u5c0f\u4e8c\u4e58\u7684\u76ee\u6807\u51fd\u6570\u7531\u4e24\u90e8\u5206\u6784\u6210\uff0c\u4e00\u90e8\u5206\u4e3a\u903c\u8fd1\u9879\uff0c\u7ea6\u675f\u66f2\u7ebf\u4e0a\u7684\u70b9\u4e0e\u7ed9\u5b9a\u7684\u578b\u503c\u70b9\u7684\u8ddd\u79bb\u4e0d\u80fd\u592a\u5927\u3002\u4e00\u90e8\u5206\u4e3a\u5149\u987a\u9879\uff0c\u6216\u8005\u79f0\u4f18\u5316\u9879\uff0c\u7ea6\u675f\u66f2\u7ebf\u8fbe\u5230\u201c\u5149\u987a\u8981\u6c42\u201d\u3002\u76ee\u6807\u51fd\u6570\u7684\u5f62\u5f0f\u662f\uff1a$$f=\\alpha(fairing\\_component)^2 + \\beta(approximating\\_component)^2$$\u4e24\u4e2a\u9879\u90fd\u662f\u63a7\u5236\u70b9P\u7684\u51fd\u6570\uff0c\u56e0\u6b64\u901a\u8fc7\u5bf9\u76ee\u6807\u51fd\u6570\u6c42\u6700\u5c0f\u503c\u7684\u65b9\u5f0f\uff0c\u53ef\u4ee5\u8ba1\u7b97\u51fa\u63a7\u5236\u70b9P\u3002\u81f3\u4e8e\u7cfb\u6570\\(\\alpha,\\beta\\)\uff0c\u5c5e\u4e8e\u5149\u987a\u9879\u4e0e\u903c\u8fd1\u9879\u7684\u6743\u91cd\uff0c\u4e00\u822c\u4f1a\u901a\u8fc7\u5b9e\u9a8c\u4e8b\u5148\u786e\u5b9a\u3002<\/p>\n<p>\u5728\u5404\u79cd\u65b9\u6cd5\u91cc\uff0c\u903c\u8fd1\u9879\u7684\u5f62\u5f0f\u4e00\u822c\u662f\u786e\u5b9a\u7684\uff0c\u7ed9\u5b9a\u70b9\\(\\{F_1,&#8230;,F_x\\}\\)\uff0c\u901a\u8fc7\u53c2\u6570\u5316\u786e\u5b9a\u4ed6\u4eec\u7684\u53c2\u6570\\(\\{u_1,&#8230;,u_x\\}\\),\u5bf9\u5e94\u66f2\u7ebf\u4e0a\u7684\u70b9\u4e3a\\(MP\\),M\u4e3a\u5bf9\u5e94\u7684\u57fa\u51fd\u6570\u77e9\u9635\uff0cP\u4e3a\u63a7\u5236\u70b9\u5411\u91cf\u3002\u90a3\u4e48\u903c\u8fd1\u9879\u5219\u662f$$MP-F=<br \/>\n\\begin{bmatrix}<br \/>\nN_0(u_1)&amp;\\cdots&amp;N_n(u_1)\\\\<br \/>\n\\vdots&amp;\\ddots&amp;\\vdots\\\\<br \/>\nN_0(u_x)&amp;\\cdots&amp;N_n(u_x)<br \/>\n\\end{bmatrix}<br \/>\n\\begin{bmatrix}<br \/>\nP_1\\\\\\vdots\\\\P_n<br \/>\n\\end{bmatrix}-<br \/>\n\\begin{bmatrix}<br \/>\nF_1\\\\\\vdots\\\\F_x<br \/>\n\\end{bmatrix}$$<\/p>\n<p>3\uff09\u5149\u987a\u9879\uff1aB\u6837\u6761\u4e8c\u6b21\u5bfc\u6570\u7684\u79ef\u5206\u7684\u8ba1\u7b97<\/p>\n<p>\u81f3\u4e8e\u5149\u987a\u9879\uff0c\u5219\u6709\u5f88\u591a\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u6cd5\uff0c\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u79cd \u5e38\u89c1\u7684\u65b9\u6cd5\uff1a\u4ee4\u66f2\u7ebf\u5728\u7ed9\u5b9a\u70b9\\(C(u_i)\\)\u4e0a\u4e8c\u9636\u5bfc\u6570\u7684\u5e73\u65b9\u548c\u7684\u79ef\u5206\u6700\u5c0f\u7684\u65b9\u6cd5\uff1a$$\\int_{t=0}^m(\\sum_{j=0}^n N_{j,p}^{\\prime\\prime}<br \/>\n(u)P_j)^2du\\rightarrow min$$\u4e3a\u7b80\u5316\u8868\u8fbe\uff0c\u4ee4\\(<br \/>\nW=\\int_{t=0}^m(\\sum_{j=0}^n N_{j,p}^{\\prime\\prime}<br \/>\n(u)P_j)^2du\\),\u53ef\u4ee5\u5f97\u51fa\u66f2\u7ebf\u62df\u5408\u7684\u76ee\u6807\u51fd\u6570\\(f\\)\u7684\u5f62\u5f0f\u4e3a\uff1a$$f=\\alpha P^TWP+\\beta(MP-F)^2$$\u6309\u7167\u6700\u5c0f\u4e8c\u4e58\u6cd5\u7684\u89e3\u6cd5:$$\\frac{\\partial f}{\\partial P}=<br \/>\n2\\alpha P^T(W)+2\\beta(MP-F)^TM=0$$\u6574\u7406\u4e00\u4e0b\uff0c\u5f97\u5230$$P^T(\\alpha(W)+\\beta(M^TM))=\\beta F^TM$$\u4e24\u8fb9\u540c\u65f6\u53d6\u8f6c\u7f6e\uff0c\u53ef\u4ee5\u5f97\u5230P\u7684\u89e3\uff1a$$P=\\beta(\\alpha(W)+\\beta(M^TM))^{-1}M^TF$$\u77e9\u9635M\uff0c\u6211\u5df2\u7ecf\u5728B\u6837\u6761\u7684\u5185\u63d2\u4e00\u8282\u4e2d\u6d89\u53ca\uff0c\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\u3002\u6bd4\u8f83\u590d\u6742\u7684\uff0c\u5c31\u662f\u62fc\u88c5\u77e9\u9635W\u3002<\/p>\n<p>\u56e0\u4e3aB\u6837\u6761\u7684\u57fa\u51fd\u6570\\(N_{i,p}\\)\u5728\u533a\u95f4\\([u_i,u_{i+p+1}\\)\u4e0a\u975e\u96f6\uff0c\u5e76\u4e14\u5bf9\u4e8e\u6bcf\u4e00\u4e2a\u533a\u95f4\\([u_k,u_{k+1})\\)\uff0c\u57fa\u51fd\u6570\u90fd\u662f\u5173\u4e8eu\u7684\u4e09\u6b21\u591a\u9879\u5f0f\u51fd\u6570\uff0c\u90a3\u4e48\u5176\u4e8c\u6b21\u5bfc\u6570\u7684\u5f62\u5f0f\u4e3a\\(au+b\\)\uff0c\u56e0\u6b64\u6211\u4eec\u9700\u8981\u6c42\u51fa\u6bcf\u4e2a\u533a\u95f4\u4e0a\u7684a,b\u7684\u503c\u3002<\/p>\n<p>\u5173\u4e8eW\u77e9\u9635\u7684\u6784\u9020\uff0c\u53ef\u4ee5\u6784\u9020\u4e00\u4e2an\u4e2a\u57fa\u51fd\u6570\\(\\times\\)n+p\u4e2a\u77e9\u9635\u7684\u8f85\u52a9\u77e9\u9635N,\u5176\u4e2d\\(N(i,j)\\)\u4ee3\u8868\u57fa\u51fd\u6570\u5bfc\u6570\\(N_{i,p}^{\\prime\\prime}\\)\u5728\u533a\u95f4\\([u_k,u_{k+1})\\)\u4e0a\u7684\u591a\u9879\u5f0f\\(au+b\\)\u7684\u7cfb\u6570a,b\u3002\\(W_{i,j}\\)\u7684\u5185\u5bb9\u5c31\u662fN\u7b2ci\u884c\u4e0e\u7b2cj\u884c\u6240\u6709\u7cfb\u6570\u76f8\u4e58\u540e\u79ef\u5206\u7684\u7ed3\u679c\uff1a<\/p>\n<p>$$W_{i,j}=\\sum_{k=0}^{k+p}\\int_{u_k}^{u_{k+1}}(N_{i,k}.a u+N_{i,k}.b)(N_{j,k}.a u+N_{j,k}.b)du$$<\/p>\n<p>B\u6837\u6761\u57fa\u51fd\u6570\u7684\u4e8c\u9636\u5bfc\u6570\u7684\u9012\u63a8\u5f62\u5f0f\u5982\u4e0b\uff1a$$N_{i,p}^{\\prime\\prime}=p\\cdot(p-1)\\cdot\\{<br \/>\n\\frac{N_{i,p-2}}{(u_{i+p-1}-u_i)(u_{i+p}-u_i)}-<br \/>\nN_{i+1,p-2}\\cdot(\\frac{1}{(u_{i+p}-u_i)(u_{i+p}-u_{i+1})}+\\frac{1}{(u_{i+p}-u_{i+1})(u_{i+p+1}-u_{i+1})})+\\\\<br \/>\n\\frac{N_{i+2,p-2}}{(u_{i+p+1}-u_{i+1})(u_{i+p+1}-u_{i+2})}<br \/>\n\\}$$<\/p>\n<p>$$=c_1\\frac{u-u_i}{u_{i+p-2}-u_i}N_{i,p-3}+<br \/>\n[c_1\\frac{u_{i+p-1}-u}{u_{i+p-1}-u_{i+1}}+<br \/>\nc_2\\frac{u-u_{i+1}}{u_{i+p-1}-u_{i+1}}]N_{i+1,p-3}+\\\\<br \/>\n[c_2\\frac{u_{i+p}-u}{u_{i+p}-u_{i+2}}+<br \/>\nc_3\\frac{u-u_{i+2}}{u_{i+p}-u_{i+2}}]N_{i+2,p-3}+<br \/>\nc_3\\frac{u_{i+p+1}-u}{u_{i+p+1}-u_{i+3}}N_{i+3,p-3}<br \/>\n$$<\/p>\n<p>\u5176\u4e2dc_1,c_2,c_3\u5206\u522b\u5bf9\u5e94\u4e0a\u9762\u7684\u5e38\u6570\u9879\u3002<\/p>\n<p>\u8fd9\u7bc7\u6587\u7ae0\u91cc\uff0c\u6211\u4ecd\u7136\u4ee5\u6700\u5e38\u7528\u7684\u4e09\u9636B\u6837\u6761\u66f2\u7ebf\u7684\u62df\u5408\u4e3a\u4f8b\u3002\u6240\u4ee5\u5bf9\u540e\u9762\u7684\u5f0f\u5b50\u91cc\uff0c\\(p=3\\)\uff0c\u5982\u679c\u8bfb\u8005\u60f3\u8981\u66f4\u6539\u66f2\u7ebf\u9636\u6b21\uff0c\u9700\u8981\u5bf9\u6211\u7279\u522b\u9488\u5bf9\u4e09\u6b21\u66f2\u7ebf\u6240\u505a\u7684\u8bf4\u660e\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<p>\u5f53p=3\u65f6\uff0c\\(N_{i,p}\\)\u5728\u533a\u95f4\\([u_i,u_{i+1}),[u_{i+1},u_{i+2}),[u_{i+2},u_{i+3}),[u_{i+3},u_{i+4})\\)\u4e0a\u5bf9\u5e94\u7684a,b\u7684\u503c\u4e0e\u4e8c\u9636\u5bfc\u6570\u5c55\u5f00\u5728\\(N_{i,p-3},N_{i+1,p-3},N_{i+2,p-3},N_{i+3,p-3}\\)\u7684\u7cfb\u6570\u4e00\u4e00\u5bf9\u5e94\u3002<\/p>\n<p>\u5f53\u8ba1\u7b97\u51fa\u6bcf\u4e2a\u533a\u95f4\u4e0a\u7684a,b\u503c\u540e\uff0c\u5c31\u53ef\u4ee5\u6c42\u51faW\u77e9\u9635\u4e86\u3002\u81ea\u6b64\uff0c\u66f2\u7ebf\u6574\u4f53\u5149\u987a\u903c\u8fd1\u7b97\u6cd5\u5c31\u4ecb\u7ecd\u5b8c\u4e86\u3002\u901a\u8fc7\u6211\u7684C++\u5b9e\u73b0\uff0c\u53ef\u4ee5\u770b\u5230\u5177\u4f53\u7684\u6548\u679c\u3002<\/p>\n<p>4\uff09\u5149\u987a\u6548\u679c<\/p>\n<p>\u56e0\u4e3a\u5b9e\u73b0\u7684\u4ee3\u7801\u8f83\u957f\uff0c\u6211\u4eec\u5148\u770b\u6548\u679c\uff0c\u628a\u4ee3\u7801\u5b9e\u73b0\u653e\u5230\u6700\u540e\u3002<\/p>\n<p>\\(\\alpha\\)\u662f\u5149\u987a\u9879\u7684\u6743\u91cd\uff0c\\(\\beta\\)\u662f\u903c\u8fd1\u9879\u7684\u6743\u91cd\uff0c\u901a\u8fc7\u8c03\u6574\u4e24\u8005\u7684\u6bd4\u4f8b\uff0c\u53ef\u4ee5\u4f7f\u66f2\u7ebf\u83b7\u5f97\u4e0d\u540c\u7684\u903c\u8fd1\u6548\u679c\u3002\u4e0b\u56fe\u662f\\(\\alpha=0.01,\\beta=1\\)\u65f6\u903c\u8fd1\u66f2\u7ebf\u4e0e\u63d2\u503c\u66f2\u7ebf\u7684\u66f2\u7387\u7684\u5bf9\u6bd4\uff0c\u53ef\u89c1\u4e8c\u8005\u503c\u57df\u5dee\u522b\u4e0d\u5927\uff0c\u903c\u8fd1\u66f2\u7ebf\u7684\u66f2\u7387\u53d8\u5316\u7a0d\u5fae\u8fde\u7eed\u4e00\u70b9\u3002\u4e8c\u8005\u51e0\u4f55\u5dee\u8ddd\u4e0d\u5927\u3002<\/p>\n<div id=\"attachment_728\" style=\"width: 810px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-728\" class=\"wp-image-728 size-full\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/approximate_0.01_1.png\" alt=\"\" width=\"800\" height=\"192\" \/><p id=\"caption-attachment-728\" class=\"wp-caption-text\">\u663e\u793a\u66f2\u7387\u8f6f\u4ef6copyright navinfo<\/p><\/div>\n<p>\u4e0b\u56fe\u662f\u589e\u5927\u5149\u987a\u9879\u6743\u91cd\\(\\alpha=1,beta=1\\)\u662f\u903c\u8fd1\u66f2\u7ebf\u7684\u66f2\u7387\u4e0e\u51e0\u4f55(\u7ea2\u7ebf\u4e3a\u903c\u8fd1\u66f2\u7ebf\uff0c\u9752\u7ebf\u4e3a\u62df\u5408\u66f2\u7ebf)\u7684\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-729\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/approximate_1_1.png\" alt=\"\" width=\"500\" height=\"238\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-730\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/geometry_approximate_1_1.png\" alt=\"\" width=\"600\" height=\"151\" \/><\/p>\n<p>\u53ef\u89c1\uff0c\u589e\u5927\u5149\u987a\u9879\u6743\u91cd\u540e\uff0c\u66f2\u7ebf\u7684\u66f2\u7387\u53d8\u5316\u66f4\u52a0\u8fde\u7eed\u4e86\uff0c\u66f4\u7b26\u5408\u201c\u5149\u987a\u201d\u7684\u6548\u679c\u4e86\u3002\u4e0b\u56fe\u662f\u7ee7\u7eed\u52a0\u5927\u5149\u987a\u5904\u7406\u6548\u679c\\(\\alpha=1,\\beta=0.01\\)\u7684\u66f2\u7387\u4e0e\u51e0\u4f55\u6548\u679c\u3002\u53ef\u89c1\uff0c\u903c\u8fd1\u66f2\u7ebf\u81ea\u52a8\u7684\u5e73\u6ed1\u4e86\u5f2f\u66f2\u8f83\u5927\u7684\u90e8\u5206\uff0c\u4ece\u800c\u8d8b\u8fd1\u4e8e\u51cf\u5c0f\u80fd\u91cf\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-731\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/approximate_1_0.01.png\" alt=\"\" width=\"500\" height=\"238\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-732\" src=\"http:\/\/www.whudj.cn\/wp-content\/uploads\/2017\/12\/geometry_approximate_1_0.01.png\" alt=\"\" width=\"587\" height=\"177\" \/><\/p>\n<p>5\uff09\u4e8c\u6b21\u578b\u7684\u6c42\u5bfc<\/p>\n<p>\u672c\u8282\u76f8\u5bf9\u4e8e\u4e4b\u524d\u7684\u7ebf\u6027\u7684\u77e9\u9635\u8ba1\u7b97\uff0c\u53c8\u5f15\u5165\u4e86\u77e9\u9635\u6c42\u5bfc\uff0c\u5c24\u5176\u662f\u4e8c\u6b21\u578b\u6c42\u5bfc\u90e8\u5206\uff0c\u6240\u4ee5\uff0c\u7279\u5730\u5c06\u5f15\u7528\u7684\u4e8c\u6b21\u578b\u6c42\u5bfc\u516c\u5f0f\u5217\u4e3e\u5982\u4e0b\uff1a$$\\frac{\\partial(x^TAx)}{\\partial x}=x^T(A+A^T)\\\\<br \/>\n\\frac{\\partial(x^TAx)}{\\partial z}=x^T(A+A^T)\\frac{\\partial x}{\\partial z}$$<\/p>\n<p>5\uff09\u6211\u7684C++\u5b9e\u73b0<\/p>\n<pre class=\"lang:c++ decode:true \">#include &lt;Dense&gt; \/\/Eigen\r\n\/*!\r\n *\\brief \u4e09\u6b21B\u6837\u6761\u6574\u4f53\u5149\u987a\u903c\u8fd1\r\n*\\ param const std::vector&lt;Point&gt; &amp; vecFitPoints \u578b\u503c\u70b9\r\n*\\ param double alpha \u5149\u987a\u9879\u6743\u91cd\r\n*\\ param double beta  \u903c\u8fd1\u9879\u6743\u91cd\r\n*\\ Returns:   BSpline \u903c\u8fd1\u7ed3\u679c\r\n*\/\r\nBSpline BSpline::CubicApproximate(const std::vector&lt;Point&gt;&amp; vecFitPoints,double alpha,double beta)\r\n{\r\n\tconst int p =3;\r\n\tBSpline bs;\r\n\tint  x = vecFitPoints.size();\r\n\tif(x&lt;p)\r\n\t{\r\n\t\tcout&lt;&lt;\"too less point !\"&lt;&lt;endl;\r\n\t\treturn bs;\r\n\t}\r\n\t\/\/\u9700\u8981\u7684\u77e9\u9635\r\n\tEigen::MatrixXd W= Eigen::MatrixXd::Zero(x+2,x+2);\r\n\tEigen::MatrixXd P= Eigen::MatrixXd::Zero(x+2,3);\r\n\tEigen::MatrixXd M= Eigen::MatrixXd::Zero(x+2,x+2);\r\n\tEigen::MatrixXd F= Eigen::MatrixXd::Zero(x+2,3);\r\n\t\/\/\u53c2\u6570\u5316\r\n\tbs.m_nDegree = p;\r\n\tbs.m_vecKnots.resize(x); \/\/x+6\u4e2a\u8282\u70b9\r\n\t\/\/\u8ba1\u7b97\u8282\u70b9\r\n\tbs.m_vecKnots[0] =0.0;\r\n\tfor (int i=1;i&lt;x;++i)\r\n\t{\r\n\t\tbs.m_vecKnots[i] = bs.m_vecKnots[i-1] \r\n\t\t+ sqrt(PointDistance(vecFitPoints[i],vecFitPoints[i-1]));\r\n\t}\r\n\t\/\/\u8282\u70b9\u9996\u5c3e\u6784\u6210p+1\u5ea6\u91cd\u590d\r\n\tbs.m_vecKnots.insert(bs.m_vecKnots.begin(),p,bs.m_vecKnots.front());\r\n\tbs.m_vecKnots.insert(bs.m_vecKnots.end(),p,bs.m_vecKnots.back());\r\n\t\r\n\t\/\/W \u77e9\u9635\r\n\tWMatrix(W,x+2,p,bs.m_vecKnots);\r\n\r\n\t\/\/M\u77e9\u9635\r\n\tstd::vector&lt;double&gt; basis_func;\r\n\tM(0,0) = 1;\r\n\tM(x-1,x+1) = 1;\r\n\tfor (int i=p+1;i&lt;x+p-1;++i)\r\n\t{\r\n\t\t\/\/c(u)\u5728 N_{i-p},...,N_i\u7b49p+1\u4e2a\u57fa\u51fd\u6570\u4e0a\u975e\u96f6\r\n\t\tbs.BasisFunc(bs.m_vecKnots[i],i,basis_func);\r\n\t\tfor (int j=i-p,k=0;j&lt;=i;++j,++k)\r\n\t\t{\r\n\t\t\tM(i-p,j) = basis_func[k];\r\n\t\t}\r\n\t}\r\n\t\/\/\u5bfc\u6570\r\n\tM(x,0) = -1;\r\n\tM(x,1) = 1;\r\n\tM(x+1,x) = -1;\r\n\tM(x+1,x+1) = 1;\r\n\t\r\n\t\/\/F\u77e9\u9635\r\n\tfor (int i=0;i&lt;x;++i)\r\n\t{\r\n\t\tF(i,0) = vecFitPoints[i].x;\r\n\t\tF(i,1) = vecFitPoints[i].y;\r\n\t\tF(i,2) = vecFitPoints[i].z;\r\n\t}\r\n\r\n\t{\r\n\t\tVec3d v0,v1,v2;\r\n\t\tBesselTanget(vecFitPoints[0],vecFitPoints[1],vecFitPoints[2],v0,v1,v2);\r\n\t\tVec3d v= v0*(bs.m_vecKnots[p+1]-bs.m_vecKnots[1])\/(double)p;\r\n\t\tF(x,0) = v.x;\r\n\t\tF(x,1) = v.y;\r\n\t\tF(x,2) = v.z;\r\n\t}\r\n\r\n\t{\r\n\t\tVec3d v0,v1,v2;\r\n\t\tBesselTanget(vecFitPoints[x-3],vecFitPoints[x-2],vecFitPoints[x-1],v0,v1,v2);\r\n\t\tVec3d v= v2*(bs.m_vecKnots[x+1+p]-bs.m_vecKnots[x+1])\/(double)p;\r\n\t\tF(x+1,0) = v.x;\r\n\t\tF(x+1,1) = v.y;\r\n\t\tF(x+1,2) = v.z;\r\n\t}\r\n\r\n\t\/\/\u89e3\u65b9\u7a0b\r\n\tP = (alpha*W+beta*M.transpose()*M).colPivHouseholderQr().solve(beta*M.transpose()*F);\r\n\r\n#ifdef _DEBUG\r\n\tcout&lt;&lt;\"P------------------\"&lt;&lt;endl&lt;&lt;P&lt;&lt;endl;\r\n#endif\r\n\r\n\t\/\/\u5c06 P\u7684\u503c\u8d4b\u7ed9 B\u6837\u6761\r\n\tbs.m_vecCVs.resize(x+2);\r\n\tfor(int i=0;i&lt;x+2;++i)\r\n\t{\r\n\t\tPoint&amp; cv = bs.m_vecCVs[i];\r\n\t\tcv.x = P(i,0);\r\n\t\tcv.y = P(i,1);\r\n\t\tcv.z = P(i,2);\r\n\t}\r\n\r\n\treturn bs;\t\r\n}\r\n\r\nvoid BSpline::WMatrix(Eigen::MatrixXd&amp; W,int n,int p,const std::vector&lt;double&gt;&amp; u)\r\n{\r\n\tstd::vector&lt;std::vector&lt;std::pair&lt;double,double&gt;&gt;&gt; BasisFuncByKnot(n);\r\n\t\/\/\u521d\u59cb\u5316\r\n\tfor (int i=0;i&lt;n;++i)\r\n\t{\r\n\t\tBasisFuncByKnot[i].resize(n+p);\r\n\t\tfor(int j=0;j&lt;n+p;++j)\r\n\t\t{\r\n\t\t\tBasisFuncByKnot[i][j].first =0;\r\n\t\t\tBasisFuncByKnot[i][j].second =0;\r\n\t\t}\r\n\t}\r\n\r\n\tstd::vector&lt;std::pair&lt;double,double&gt;&gt; a_b_array;\r\n\tfor (int i=0;i&lt;n;++i)\r\n\t{\r\n\t\t_SecondDerivativeCoefficient(i,u,a_b_array);\r\n\t\tstd::copy(a_b_array.begin(),a_b_array.end(),BasisFuncByKnot[i].begin()+i);\r\n\t}\r\n\t\/\/\u57fa\u51fd\u6570\/\/\u5176\u5b9e\u8fd9\u662f\u4e00\u4e2a\u5bf9\u79f0\u77e9\u9635\uff0c\u6211\u4e3a\u4e86\u65b9\u4fbf\uff0c\u591a\u7b97\u4e86\u4e00\u500d\r\n\tfor (int i=0;i&lt;n;++i)\r\n\t{\r\n\t\tfor (int j=0;j&lt;n;++j)\r\n\t\t{\r\n\t\t\tdouble ret =0;\r\n\t\t\t\/\/\u533a\u95f4\r\n\t\t\tfor (int k=0;k&lt;n+p;++k)\r\n\t\t\t{\r\n\t\t\t\tconst std::pair&lt;double,double&gt; basis_i = BasisFuncByKnot[i][k];\r\n\t\t\t\tconst std::pair&lt;double,double&gt; basis_j = BasisFuncByKnot[j][k];\r\n\r\n\t\t\t\tret +=PolynomialIntegral(basis_i.first * basis_j.first,basis_i.first*basis_j.second+\r\n\t\t\t\t\tbasis_i.second*basis_j.first,basis_i.second*basis_j.second,u[k],u[k+1]); \r\n\t\t\t}\r\n\t\t\tW(i,j) = ret;\r\n\t\t}\r\n\t}\r\n}\r\n\r\nvoid BSpline::_SecondDerivativeCoefficient(int i,const std::vector&lt;double&gt;&amp; u,std::vector&lt;std::pair&lt;double,double&gt;&gt;&amp; a_b_array)\r\n{\r\n\tconst int p = 3;\r\n\tdouble c1,c2,c3;\r\n\tc1=c2=c3=0;\r\n\r\n\tdouble div =(u[i+p-1]-u[i])*(u[i+p]-u[i]);\r\n\tif(div !=0)c1=p*(p-1)\/div;\r\n\r\n\tdiv=(u[i+p]-u[i])*(u[i+p]-u[i+1]);\r\n\tif(div !=0)c2-=p*(p-1)\/div;\r\n\tdiv=(u[i+p]-u[i+1])*(u[i+p+1]-u[i+1]);\r\n\tif(div !=0)c2-=p*(p-1)\/div;\r\n\r\n\tdiv = (u[i+p+1]-u[i+1])*(u[i+p+1]-u[i+2]);\r\n\tif(div !=0)c3 =p*(p-1)\/div;\r\n\r\n\ta_b_array.resize(p+1);\r\n\tfor (int i=0;i&lt;p+1;++i)\r\n\t{\r\n\t\ta_b_array[i].first =0;\r\n\t\ta_b_array[i].second =0;\r\n\t}\r\n\t\r\n\tdiv = u[i+p-2]-u[i];\r\n\tif(c1!=0&amp;&amp;div!=0)\r\n\t{\r\n\t\ta_b_array[0].first = c1\/div;\r\n\t\ta_b_array[0].second = -c1*u[i]\/div;\r\n\t}\r\n\r\n\tdiv =u[i+p-1]-u[i+1];\r\n\tif(div !=0)\r\n\t{\r\n\t\ta_b_array[1].first = (c2-c1)\/div;\r\n\t\ta_b_array[1].second = (c1*u[i+p-1]-c2*u[i+1])\/div;\r\n\t}\r\n\r\n\tdiv =u[i+p]-u[i+2];\r\n\tif(div !=0)\r\n\t{\r\n\t\ta_b_array[2].first = (c3-c2)\/div;\r\n\t\ta_b_array[2].second = (c2*u[i+p]-c3*u[i+2])\/div;\r\n\t}\r\n\r\n\tdiv =u[i+p+1]-u[i+3];\r\n\tif(c3!=0&amp;&amp;div!=0)\r\n\t{\r\n\t\ta_b_array[3].first = -c3\/div;\r\n\t\ta_b_array[3].second = u[i+p+1]*c3\/div;\r\n\t}\r\n}\r\n\r\ndouble BSpline::PolynomialIntegral(double quad,double linear,double con,double start,double end)\r\n{\r\n\tif(end == start)\r\n\t\treturn 0;\r\n\r\n\tdouble ret =0;\r\n\tif(quad !=0)\r\n\t{\r\n\t\tret +=(end*end*end - start*start*start )*quad\/3;\r\n\t}\r\n\tif(linear !=0)\r\n\t{\r\n\t\tret +=(end*end -start*start)*linear\/2;\r\n\t}\r\n\tif(con !=0)\r\n\t{\r\n\t\tret +=(end-start)*con;\r\n\t}\r\n\r\n\treturn ret;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n<hr \/>\n<p>\u53c2\u8003\u6587\u732e\uff1a<\/p>\n<p>\u7f57\u536b\u5170. B\u6837\u6761\u66f2\u7ebf\u7684\u5149\u987a[D]. \u6d59\u6c5f\u5927\u5b66, 2003.<\/p>\n<p>\u5170\u6d69. NURBS\u66f2\u7ebf\u6574\u4f53\u5149\u987a\u903c\u8fd1\u7b97\u6cd5\u7814\u7a76\u4e0e\u5e94\u7528[D]. \u897f\u5b89\u7406\u5de5\u5927\u5b66, 2008.<\/p>\n<p><a href=\"https:\/\/atmos.washington.edu\/~dennis\/MatrixCalculus.pdf\">Randal J. Barnes Matrix Differentiation<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u66f2\u7ebf\u62df\u5408\u5305\u542b\u4e24\u4e2a\u65b9\u9762\uff0c\u63d2\u503c(interpolation)\u548c\u903c\u8fd1(approxim &hellip; <a href=\"http:\/\/www.whudj.cn\/?p=672\">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":[29,8,30],"_links":{"self":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/672"}],"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=672"}],"version-history":[{"count":58,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions"}],"predecessor-version":[{"id":737,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=\/wp\/v2\/posts\/672\/revisions\/737"}],"wp:attachment":[{"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=672"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.whudj.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}