import{_ as l,c as Q,b as a,a as T,d as n,o as s}from"./app-CeXFFiPz.js";const o="/images/2025/03/bezier_2_big.gif",e={},m={class:"MathJax",jax:"SVG",style:{position:"relative"}},p={style:{"vertical-align":"-0.375ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.44ex",height:"1.92ex",role:"img",focusable:"false",viewBox:"0 -683 1078.6 848.6","aria-hidden":"true"},r={class:"MathJax",jax:"SVG",style:{position:"relative"}},d={style:{"vertical-align":"-0.339ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.44ex",height:"1.885ex",role:"img",focusable:"false",viewBox:"0 -683 1078.6 833","aria-hidden":"true"},i={class:"MathJax",jax:"SVG",style:{position:"relative"}},c={style:{"vertical-align":"-0.339ex"},xmlns:"http://www.w3.org/2000/svg",width:"2.44ex",height:"1.885ex",role:"img",focusable:"false",viewBox:"0 -683 1078.6 833","aria-hidden":"true"},g={class:"MathJax",jax:"SVG",style:{position:"relative"}},H={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"4.294ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1898 1000","aria-hidden":"true"},u={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},h={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"39.003ex",height:"2.565ex",role:"img",focusable:"false",viewBox:"0 -883.9 17239.2 1133.9","aria-hidden":"true"},L={class:"MathJax",jax:"SVG",style:{position:"relative"}},k={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"0.817ex",height:"1.441ex",role:"img",focusable:"false",viewBox:"0 -626 361 637","aria-hidden":"true"},f={class:"MathJax",jax:"SVG",style:{position:"relative"}},M={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"4.294ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1898 1000","aria-hidden":"true"},w={class:"MathJax",jax:"SVG",style:{position:"relative"}},Z={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"0.817ex",height:"1.441ex",role:"img",focusable:"false",viewBox:"0 -626 361 637","aria-hidden":"true"},x={class:"MathJax",jax:"SVG",style:{position:"relative"}},V={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"3.638ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1608 1000","aria-hidden":"true"},y={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},b={style:{"vertical-align":"-1.344ex"},xmlns:"http://www.w3.org/2000/svg",width:"24.367ex",height:"4.208ex",role:"img",focusable:"false",viewBox:"0 -1265.9 10770.1 1860","aria-hidden":"true"},v={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},D={style:{"vertical-align":"-7.123ex"},xmlns:"http://www.w3.org/2000/svg",width:"19.629ex",height:"15.377ex",role:"img",focusable:"false",viewBox:"0 -3648.4 8676.2 6796.7","aria-hidden":"true"},j={class:"MathJax",jax:"SVG",style:{position:"relative"}},B={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"3.638ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1608 1000","aria-hidden":"true"},C={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},A={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"22.249ex",height:"3.086ex",role:"img",focusable:"false",viewBox:"0 -1114.2 9834 1364.2","aria-hidden":"true"},S={class:"MathJax",jax:"SVG",style:{position:"relative"}},q={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"4.118ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1820 1000","aria-hidden":"true"},E={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},J={style:{"vertical-align":"-8.304ex"},xmlns:"http://www.w3.org/2000/svg",width:"77.97ex",height:"17.739ex",role:"img",focusable:"false",viewBox:"0 -4170.3 34462.6 7840.6","aria-hidden":"true"},G={class:"MathJax",jax:"SVG",style:{position:"relative"}},O={style:{"vertical-align":"-0.186ex"},xmlns:"http://www.w3.org/2000/svg",width:"6.725ex",height:"1.692ex",role:"img",focusable:"false",viewBox:"0 -666 2972.6 748","aria-hidden":"true"},F={class:"MathJax",jax:"SVG",style:{position:"relative"}},R={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"6.192ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 2737 1000","aria-hidden":"true"},P={class:"MathJax",jax:"SVG",style:{position:"relative"}},N={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.444ex",height:"1.742ex",role:"img",focusable:"false",viewBox:"0 -759 638.5 770","aria-hidden":"true"},z={class:"MathJax",jax:"SVG",style:{position:"relative"}},X={style:{"vertical-align":"0"},xmlns:"http://www.w3.org/2000/svg",width:"1.541ex",height:"1.545ex",role:"img",focusable:"false",viewBox:"0 -683 681 683","aria-hidden":"true"},I={class:"MathJax",jax:"SVG",display:"true",width:"full",style:{"min-width":"24.174ex",position:"relative"}},Y={style:{"vertical-align":"-0.632ex","min-width":"24.174ex"},xmlns:"http://www.w3.org/2000/svg",width:"100%",height:"2.396ex",role:"img",focusable:"false","aria-hidden":"true"},K={class:"MathJax",jax:"SVG",style:{position:"relative"}},U={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"17.004ex",height:"2.452ex",role:"img",focusable:"false",viewBox:"0 -833.9 7515.7 1083.9","aria-hidden":"true"},W={class:"MathJax",jax:"SVG",style:{position:"relative"}},$={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"4.118ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1820 1000","aria-hidden":"true"},_={class:"MathJax",jax:"SVG",style:{position:"relative"}},a2={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"3.638ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 1608 1000","aria-hidden":"true"},t2={class:"MathJax",jax:"SVG",style:{position:"relative"}},Q2={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.444ex",height:"1.742ex",role:"img",focusable:"false",viewBox:"0 -759 638.5 770","aria-hidden":"true"},n2={class:"MathJax",jax:"SVG",style:{position:"relative"}},s2={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"12.332ex",height:"2.262ex",role:"img",focusable:"false",viewBox:"0 -750 5450.8 1000","aria-hidden":"true"},T2={class:"MathJax",jax:"SVG",style:{position:"relative"}},l2={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.444ex",height:"1.742ex",role:"img",focusable:"false",viewBox:"0 -759 638.5 770","aria-hidden":"true"},o2={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},e2={style:{"vertical-align":"-0.566ex"},xmlns:"http://www.w3.org/2000/svg",width:"13.965ex",height:"2.396ex",role:"img",focusable:"false",viewBox:"0 -809 6172.7 1059","aria-hidden":"true"},m2={class:"MathJax",jax:"SVG",display:"true",style:{position:"relative"}},p2={style:{"vertical-align":"-2.183ex"},xmlns:"http://www.w3.org/2000/svg",width:"23.089ex",height:"5.517ex",role:"img",focusable:"false",viewBox:"0 -1473.8 10205.2 2438.5","aria-hidden":"true"},r2={class:"MathJax",jax:"SVG",style:{position:"relative"}},d2={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"0.817ex",height:"1.441ex",role:"img",focusable:"false",viewBox:"0 -626 361 637","aria-hidden":"true"},i2={class:"MathJax",jax:"SVG",style:{position:"relative"}},c2={style:{"vertical-align":"-0.025ex"},xmlns:"http://www.w3.org/2000/svg",width:"1.444ex",height:"1.742ex",role:"img",focusable:"false",viewBox:"0 -759 638.5 770","aria-hidden":"true"},g2={class:"MathJax",jax:"SVG",style:{position:"relative"}},H2={style:{"vertical-align":"-0.375ex"},xmlns:"http://www.w3.org/2000/svg",width:"5.638ex",height:"1.791ex",role:"img",focusable:"false",viewBox:"0 -626 2492.1 791.6","aria-hidden":"true"};function u2(h2,t){return s(),Q("div",null,[t[96]||(t[96]=a("h1",{id:"匀速贝塞尔曲线运动的实现",tabindex:"-1"},[a("a",{class:"header-anchor",href:"#匀速贝塞尔曲线运动的实现"},[a("span",null,"匀速贝塞尔曲线运动的实现")])],-1)),a("p",null,[t[8]||(t[8]=n("二次贝塞尔曲线通常以如下方式构建,给定二维平面上的固定点")),a("mjx-container",m,[(s(),Q("svg",p,t[0]||(t[0]=[T('',1)]))),t[1]||(t[1]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msub",null,[a("mi",null,"P"),a("mn",null,"0")])])],-1))]),t[9]||(t[9]=n(", ")),a("mjx-container",r,[(s(),Q("svg",d,t[2]||(t[2]=[T('',1)]))),t[3]||(t[3]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msub",null,[a("mi",null,"P"),a("mn",null,"1")])])],-1))]),t[10]||(t[10]=n(", ")),a("mjx-container",i,[(s(),Q("svg",c,t[4]||(t[4]=[T('',1)]))),t[5]||(t[5]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msub",null,[a("mi",null,"P"),a("mn",null,"2")])])],-1))]),t[11]||(t[11]=n(",用")),a("mjx-container",g,[(s(),Q("svg",H,t[6]||(t[6]=[T('',1)]))),t[7]||(t[7]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"B"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[12]||(t[12]=n("表示该条曲线"))]),a("mjx-container",u,[(s(),Q("svg",h,t[13]||(t[13]=[T('',1)]))),t[14]||(t[14]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mi",{mathvariant:"bold-italic"},"B"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")"),a("mo",null,"="),a("mo",{stretchy:"false"},"("),a("mn",null,"1"),a("mo",null,"−"),a("mi",null,"t"),a("msup",null,[a("mo",{stretchy:"false"},")"),a("mn",null,"2")]),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"0")]),a("mo",null,"+"),a("mn",null,"2"),a("mi",null,"t"),a("mo",{stretchy:"false"},"("),a("mn",null,"1"),a("mo",null,"−"),a("mi",null,"t"),a("mo",{stretchy:"false"},")"),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"1")]),a("mo",null,"+"),a("msup",null,[a("mi",null,"t"),a("mn",null,"2")]),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"2")])])],-1))]),t[97]||(t[97]=a("p",null,"用一个动画来演示,可以更加清楚的表明这条曲线的构建过程",-1)),t[98]||(t[98]=a("figure",null,[a("img",{src:o,alt:"",tabindex:"0",loading:"lazy"}),a("figcaption")],-1)),a("p",null,[t[17]||(t[17]=n("如果")),a("mjx-container",L,[(s(),Q("svg",k,t[15]||(t[15]=[a("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[a("g",{"data-mml-node":"math"},[a("g",{"data-mml-node":"mi"},[a("path",{"data-c":"1D461",d:"M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"})])])],-1)]))),t[16]||(t[16]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"t")])],-1))]),t[18]||(t[18]=n("变量本身是线性变化的话,这条贝塞尔曲线的生成过程是并不是匀速的,通常都是两头快中间慢。"))]),t[99]||(t[99]=a("iframe",{width:"100%",height:"270",frameborder:"0",src:"/html/bezier.html?uniformSpeed=0"},null,-1)),a("p",null,[t[25]||(t[25]=n("可以看出中间的点较为密集,而两边则较为稀疏。 如何想要得到匀速的贝塞尔曲线运动呢?比如我们在某款游戏中设计了一条贝塞尔曲线的路径,如何实现玩家匀速在这条路径上运动呢?​  首先需要求得")),a("mjx-container",f,[(s(),Q("svg",M,t[19]||(t[19]=[T('',1)]))),t[20]||(t[20]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"B"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[26]||(t[26]=n("相对于")),a("mjx-container",w,[(s(),Q("svg",Z,t[21]||(t[21]=[a("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[a("g",{"data-mml-node":"math"},[a("g",{"data-mml-node":"mi"},[a("path",{"data-c":"1D461",d:"M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"})])])],-1)]))),t[22]||(t[22]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"t")])],-1))]),t[27]||(t[27]=n("的速度公式")),a("mjx-container",x,[(s(),Q("svg",V,t[23]||(t[23]=[T('',1)]))),t[24]||(t[24]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))])]),a("mjx-container",y,[(s(),Q("svg",b,t[28]||(t[28]=[T('',1)]))),t[29]||(t[29]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")"),a("mo",null,"="),a("msqrt",null,[a("msubsup",null,[a("mi",null,"B"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mi",null,"x")]),a("mrow",{"data-mjx-texclass":"ORD"},[a("msup",null,[a("mi"),a("mo",{"data-mjx-alternate":"1"},"′")])])]),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("msup",null,[a("mo",{stretchy:"false"},")"),a("mn",null,"2")]),a("mo",null,"+"),a("msubsup",null,[a("mi",null,"B"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mi",null,"y")]),a("mrow",{"data-mjx-texclass":"ORD"},[a("msup",null,[a("mi"),a("mo",{"data-mjx-alternate":"1"},"′")])])]),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("msup",null,[a("mo",{stretchy:"false"},")"),a("mn",null,"2")])])])],-1))]),t[100]||(t[100]=a("p",null,"为了简化公式,定义如下变量",-1)),a("mjx-container",v,[(s(),Q("svg",D,t[30]||(t[30]=[T('',1)]))),t[31]||(t[31]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mtable",{displaystyle:"true",columnalign:"right left",columnspacing:"0em",rowspacing:"3pt"},[a("mtr",null,[a("mtd",null,[a("mi",{mathvariant:"bold-italic"},"a")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"0")]),a("mo",null,"−"),a("mn",null,"2"),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"1")]),a("mo",null,"+"),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"2")])])]),a("mtr",null,[a("mtd",null,[a("mi",{mathvariant:"bold-italic"},"b")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("mn",null,"2"),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"1")]),a("mo",null,"−"),a("mn",null,"2"),a("msub",null,[a("mi",{mathvariant:"bold-italic"},"P"),a("mn",{mathvariant:"bold"},"0")])])]),a("mtr",null,[a("mtd",null,[a("mi",null,"A")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("mn",null,"4"),a("mo",{stretchy:"false"},"("),a("msubsup",null,[a("mi",null,"a"),a("mi",null,"x"),a("mn",null,"2")]),a("mo",null,"+"),a("msubsup",null,[a("mi",null,"a"),a("mi",null,"y"),a("mn",null,"2")]),a("mo",{stretchy:"false"},")")])]),a("mtr",null,[a("mtd",null,[a("mi",null,"B")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("mn",null,"4"),a("mo",{stretchy:"false"},"("),a("msub",null,[a("mi",null,"a"),a("mi",null,"x")]),a("msub",null,[a("mi",null,"b"),a("mi",null,"x")]),a("mo",null,"+"),a("msub",null,[a("mi",null,"a"),a("mi",null,"y")]),a("msub",null,[a("mi",null,"b"),a("mi",null,"y")]),a("mo",{stretchy:"false"},")")])]),a("mtr",null,[a("mtd",null,[a("mi",null,"C")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("msubsup",null,[a("mi",null,"b"),a("mi",null,"x"),a("mn",null,"2")]),a("mo",null,"+"),a("msubsup",null,[a("mi",null,"b"),a("mi",null,"y"),a("mn",null,"2")])])])])])],-1))]),a("p",null,[t[34]||(t[34]=n("计算出")),a("mjx-container",j,[(s(),Q("svg",B,t[32]||(t[32]=[T('',1)]))),t[33]||(t[33]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[35]||(t[35]=n("可以表达为"))]),a("mjx-container",C,[(s(),Q("svg",A,t[36]||(t[36]=[T('',1)]))),t[37]||(t[37]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")"),a("mo",null,"="),a("msqrt",null,[a("mi",null,"A"),a("msup",null,[a("mi",null,"t"),a("mn",null,"2")]),a("mo",null,"+"),a("mi",null,"B"),a("mi",null,"t"),a("mo",null,"+"),a("mi",null,"C")])])],-1))]),a("p",null,[t[40]||(t[40]=n("根据这个公式,求得贝塞尔曲线的长度公式")),a("mjx-container",S,[(s(),Q("svg",q,t[38]||(t[38]=[T('',1)]))),t[39]||(t[39]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[41]||(t[41]=n("为"))]),a("mjx-container",E,[(s(),Q("svg",J,t[42]||(t[42]=[T('',1)]))),t[43]||(t[43]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mtable",{displaystyle:"true",columnalign:"right left",columnspacing:"0em",rowspacing:"3pt"},[a("mtr",null,[a("mtd",null,[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")]),a("mtd",null,[a("mi"),a("mo",null,"="),a("msubsup",null,[a("mo",{"data-mjx-texclass":"OP"},"∫"),a("mn",null,"0"),a("mi",null,"t")]),a("msqrt",null,[a("mi",null,"A"),a("msup",null,[a("mi",null,"x"),a("mn",null,"2")]),a("mo",null,"+"),a("mi",null,"B"),a("mi",null,"x"),a("mo",null,"+"),a("mi",null,"C")]),a("mi",null,"d"),a("mi",null,"x")])]),a("mtr",null,[a("mtd"),a("mtd",null,[a("mi"),a("mo",null,"="),a("mfrac",null,[a("mn",null,"1"),a("mrow",null,[a("mn",null,"8"),a("msup",null,[a("mi",null,"A"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mn",null,"3"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mo",null,"/")]),a("mn",null,"2")])])])]),a("mrow",{"data-mjx-texclass":"OPEN"},[a("mo",{minsize:"2.047em",maxsize:"2.047em"},"(")]),a("mn",null,"2"),a("msqrt",null,[a("mi",null,"A")]),a("mrow",{"data-mjx-texclass":"INNER"},[a("mo",{"data-mjx-texclass":"OPEN"},"["),a("mn",null,"2"),a("mi",null,"A"),a("mi",null,"t"),a("msqrt",null,[a("mi",null,"A"),a("msup",null,[a("mi",null,"t"),a("mn",null,"2")]),a("mo",null,"+"),a("mi",null,"B"),a("mi",null,"t"),a("mo",null,"+"),a("mi",null,"C")]),a("mo",null,"+"),a("mi",null,"B"),a("mrow",{"data-mjx-texclass":"INNER"},[a("mo",{"data-mjx-texclass":"OPEN"},"("),a("msqrt",null,[a("mi",null,"A"),a("msup",null,[a("mi",null,"t"),a("mn",null,"2")]),a("mo",null,"+"),a("mi",null,"B"),a("mi",null,"t"),a("mo",null,"+"),a("mi",null,"C")]),a("mo",null,"−"),a("msqrt",null,[a("mi",null,"C")]),a("mo",{"data-mjx-texclass":"CLOSE"},")")]),a("mo",{"data-mjx-texclass":"CLOSE"},"]")])])]),a("mtr",null,[a("mtd"),a("mtd",null,[a("mstyle",{scriptlevel:"0"},[a("mspace",{width:"1em"})]),a("mo",null,"+"),a("mo",{stretchy:"false"},"("),a("msup",null,[a("mi",null,"B"),a("mn",null,"2")]),a("mo",null,"−"),a("mn",null,"4"),a("mi",null,"A"),a("mi",null,"C"),a("mo",{stretchy:"false"},")"),a("mrow",{"data-mjx-texclass":"INNER"},[a("mo",{"data-mjx-texclass":"OPEN"},"["),a("mi",null,"l"),a("mi",null,"n"),a("mo",{stretchy:"false"},"("),a("mi",null,"B"),a("mo",null,"+"),a("mn",null,"2"),a("msqrt",null,[a("mi",null,"A"),a("mi",null,"C")]),a("mo",{stretchy:"false"},")"),a("mo",null,"−"),a("mi",null,"l"),a("mi",null,"n"),a("mrow",{"data-mjx-texclass":"INNER"},[a("mo",{"data-mjx-texclass":"OPEN"},"("),a("mi",null,"B"),a("mo",null,"+"),a("mn",null,"2"),a("mi",null,"A"),a("mi",null,"t"),a("mo",null,"+"),a("mn",null,"2"),a("msqrt",null,[a("mi",null,"A")]),a("msqrt",null,[a("mi",null,"A"),a("msup",null,[a("mi",null,"t"),a("mn",null,"2")]),a("mo",null,"+"),a("mi",null,"B"),a("mi",null,"t"),a("mo",null,"+"),a("mi",null,"C")]),a("mo",{"data-mjx-texclass":"CLOSE"},")")]),a("mo",{"data-mjx-texclass":"CLOSE"},"]")]),a("mrow",{"data-mjx-texclass":"CLOSE"},[a("mo",{minsize:"2.047em",maxsize:"2.047em"},")")])])])])])],-1))]),a("p",null,[t[52]||(t[52]=n("特别当")),a("mjx-container",G,[(s(),Q("svg",O,t[44]||(t[44]=[T('',1)]))),t[45]||(t[45]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"t"),a("mo",null,"="),a("mn",null,"1.0")])],-1))]),t[53]||(t[53]=n("时,")),a("mjx-container",F,[(s(),Q("svg",R,t[46]||(t[46]=[T('',1)]))),t[47]||(t[47]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mn",null,"1.0"),a("mo",{stretchy:"false"},")")])],-1))]),t[54]||(t[54]=n("就是这条曲线的总长度。 设")),a("mjx-container",P,[(s(),Q("svg",N,t[48]||(t[48]=[T('',1)]))),t[49]||(t[49]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")])])],-1))]),t[55]||(t[55]=n("是能够使")),a("mjx-container",z,[(s(),Q("svg",X,t[50]||(t[50]=[a("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[a("g",{"data-mml-node":"math"},[a("g",{"data-mml-node":"mi"},[a("path",{"data-c":"1D43F",d:"M228 637Q194 637 192 641Q191 643 191 649Q191 673 202 682Q204 683 217 683Q271 680 344 680Q485 680 506 683H518Q524 677 524 674T522 656Q517 641 513 637H475Q406 636 394 628Q387 624 380 600T313 336Q297 271 279 198T252 88L243 52Q243 48 252 48T311 46H328Q360 46 379 47T428 54T478 72T522 106T564 161Q580 191 594 228T611 270Q616 273 628 273H641Q647 264 647 262T627 203T583 83T557 9Q555 4 553 3T537 0T494 -1Q483 -1 418 -1T294 0H116Q32 0 32 10Q32 17 34 24Q39 43 44 45Q48 46 59 46H65Q92 46 125 49Q139 52 144 61Q147 65 216 339T285 628Q285 635 228 637Z"})])])],-1)]))),t[51]||(t[51]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"L")])],-1))]),t[56]||(t[56]=n("实现匀速运动的自变量,那么此时曲线长度应该满足线性增长,也就是"))]),a("mjx-container",I,[(s(),Q("svg",Y,t[57]||(t[57]=[T('',1)]))),t[58]||(t[58]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mtable",{displaystyle:"true"},[a("mlabeledtr",null,[a("mtd",null,[a("mtext",null,"(1)")]),a("mtd",null,[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",{stretchy:"false"},")"),a("mo",null,"="),a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mn",null,"1.0"),a("mo",{stretchy:"false"},")"),a("mi",null,"t")])])])])],-1))]),a("p",null,[t[71]||(t[71]=n("也就是")),a("mjx-container",K,[(s(),Q("svg",U,t[59]||(t[59]=[T('',1)]))),t[60]||(t[60]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",null,"="),a("msup",null,[a("mi",null,"L"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mo",null,"−"),a("mn",null,"1")])]),a("mo",{stretchy:"false"},"("),a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mn",null,"1.0"),a("mo",{stretchy:"false"},")"),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[72]||(t[72]=n(",由于")),a("mjx-container",W,[(s(),Q("svg",$,t[61]||(t[61]=[T('',1)]))),t[62]||(t[62]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[73]||(t[73]=n("函数非常复杂,直接求其逆函数的解析解几乎不可能,还好我们知道它的导数为")),a("mjx-container",_,[(s(),Q("svg",a2,t[63]||(t[63]=[T('',1)]))),t[64]||(t[64]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("mi",null,"t"),a("mo",{stretchy:"false"},")")])],-1))]),t[74]||(t[74]=n(",在实际使用中,可以使用")),t[75]||(t[75]=a("a",{href:"https://en.wikipedia.org/wiki/Newton%27s_method",target:"_blank",rel:"noopener noreferrer"},"牛顿切线法",-1)),t[76]||(t[76]=n("获得")),a("mjx-container",t2,[(s(),Q("svg",Q2,t[65]||(t[65]=[T('',1)]))),t[66]||(t[66]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")])])],-1))]),t[77]||(t[77]=n("的数值解。")),t[78]||(t[78]=a("br",null,null,-1)),t[79]||(t[79]=n(" 设")),a("mjx-container",n2,[(s(),Q("svg",s2,t[67]||(t[67]=[T('',1)]))),t[68]||(t[68]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msub",null,[a("mi",null,"L"),a("mi",null,"t")]),a("mo",null,"="),a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("mn",null,"1.0"),a("mo",{stretchy:"false"},")"),a("mi",null,"t")])],-1))]),t[80]||(t[80]=n(",视")),a("mjx-container",T2,[(s(),Q("svg",l2,t[69]||(t[69]=[T('',1)]))),t[70]||(t[70]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")])])],-1))]),t[81]||(t[81]=n("为未知数,根据公式1有以下方程"))]),a("mjx-container",o2,[(s(),Q("svg",e2,t[82]||(t[82]=[T('',1)]))),t[83]||(t[83]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",{stretchy:"false"},")"),a("mo",null,"−"),a("msub",null,[a("mi",null,"L"),a("mi",null,"t")]),a("mo",null,"="),a("mn",null,"0")])],-1))]),t[101]||(t[101]=a("p",null,"根据牛顿切线法,求解的迭代公式为:",-1)),a("mjx-container",m2,[(s(),Q("svg",p2,t[84]||(t[84]=[T('',1)]))),t[85]||(t[85]=a("mjx-assistive-mml",{unselectable:"on",display:"block"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML",display:"block"},[a("msubsup",null,[a("mi",null,"t"),a("mrow",{"data-mjx-texclass":"ORD"},[a("mi",null,"n"),a("mo",null,"+"),a("mn",null,"1")]),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",null,"="),a("msubsup",null,[a("mi",null,"t"),a("mi",null,"n"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",null,"−"),a("mfrac",null,[a("mrow",null,[a("mi",null,"L"),a("mo",{stretchy:"false"},"("),a("msubsup",null,[a("mi",null,"t"),a("mi",null,"n"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",{stretchy:"false"},")"),a("mo",null,"−"),a("msub",null,[a("mi",null,"L"),a("mi",null,"t")])]),a("mrow",null,[a("mi",null,"s"),a("mo",{stretchy:"false"},"("),a("msubsup",null,[a("mi",null,"t"),a("mi",null,"n"),a("mo",{"data-mjx-alternate":"1"},"′")]),a("mo",{stretchy:"false"},")")])])])],-1))]),a("p",null,[t[92]||(t[92]=n("由于")),a("mjx-container",r2,[(s(),Q("svg",d2,t[86]||(t[86]=[a("g",{stroke:"currentColor",fill:"currentColor","stroke-width":"0",transform:"scale(1,-1)"},[a("g",{"data-mml-node":"math"},[a("g",{"data-mml-node":"mi"},[a("path",{"data-c":"1D461",d:"M26 385Q19 392 19 395Q19 399 22 411T27 425Q29 430 36 430T87 431H140L159 511Q162 522 166 540T173 566T179 586T187 603T197 615T211 624T229 626Q247 625 254 615T261 596Q261 589 252 549T232 470L222 433Q222 431 272 431H323Q330 424 330 420Q330 398 317 385H210L174 240Q135 80 135 68Q135 26 162 26Q197 26 230 60T283 144Q285 150 288 151T303 153H307Q322 153 322 145Q322 142 319 133Q314 117 301 95T267 48T216 6T155 -11Q125 -11 98 4T59 56Q57 64 57 83V101L92 241Q127 382 128 383Q128 385 77 385H26Z"})])])],-1)]))),t[87]||(t[87]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("mi",null,"t")])],-1))]),t[93]||(t[93]=n("和")),a("mjx-container",i2,[(s(),Q("svg",c2,t[88]||(t[88]=[T('',1)]))),t[89]||(t[89]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msup",null,[a("mi",null,"t"),a("mo",{"data-mjx-alternate":"1"},"′")])])],-1))]),t[94]||(t[94]=n("相差不大,可以设")),a("mjx-container",g2,[(s(),Q("svg",H2,t[90]||(t[90]=[T('',1)]))),t[91]||(t[91]=a("mjx-assistive-mml",{unselectable:"on",display:"inline"},[a("math",{xmlns:"http://www.w3.org/1998/Math/MathML"},[a("msub",null,[a("mi",null,"t"),a("mn",null,"0")]),a("mo",null,"="),a("mi",null,"t")])],-1))]),t[95]||(t[95]=n("来开始求解,以下是修正后的匀速贝塞尔曲线"))]),t[102]||(t[102]=a("iframe",{width:"100%",height:"270",frameborder:"0",src:"/html/bezier.html?uniformSpeed=1"},null,-1)),t[103]||(t[103]=T(`

上面是使用javascript实现的互动曲线,核心代码如下

class QuadBezierLine {
	constructor(_p0, _p1, _p2, _step, _uniformSpeed) {
		this.step=_step;
		this.points=[];
		this.uniformSpeed=_uniformSpeed;
		this.updatePoints(_p0, _p1, _p2);
	}
	
	//Speed(t_) = Sqrt[A*t*t+B*t+C]
	speed(t) {
		return Math.sqrt(this.A * t * t + this.B * t + this.C);
	}
	
	//Length(t) = Integrate[Speed[t], t]
	//Length(t_)=((2*Sqrt[A]*(2*A*t*Sqrt[C+t*(B+A*t)]+B*(Sqrt[C + t*(B + A*t)]-Sqrt[C])) +
	//	(B^2-4*A*C)(Log[B+2*Sqrt[A]*Sqrt[C]]-Log[B+2*A*t+2*Sqrt[A]*Sqrt[C+t*(B+A*t)]]))/
	//	(8* A^(3/2)));
	length(t) {
		let temp1 = Math.sqrt(this.C + t * (this.B + this.A * t));
		let temp2 = (2 * this.A * t * temp1 + this.B * (temp1 - Math.sqrt(this.C)));
		let temp3 = Math.log(this.B + 2 * Math.sqrt(this.A) * Math.sqrt(this.C));
		let temp4 = Math.log(this.B + 2 * this.A * t + 2 * Math.sqrt(this.A) * temp1);
		let temp5 = 2 * Math.sqrt(this.A) * temp2;
		let temp6 = (this.B * this.B - 4 * this.A * this.C) * (temp3 - temp4);
		return (temp5 + temp6) / (8 * Math.pow(this.A, 1.5));
	}
	
	//X(n+1) = Xn - F(Xn)/F'(Xn)
	invertLength(t, len) {
		let t1 = t, t2;
		do {
			t2 = t1 - (this.length(t1) - len) / this.speed(t1);
			if (Math.abs(t1 - t2) < 0.000001)
				break;
			t1 = t2;
		} while (true);
		return t2;
	}
	
	updatePoints(_p0, _p1, _p2) {
		this.p0=_p0;
		this.p1=_p1;
		this.p2=_p2;
		
		let ax = this.p0.x - 2 * this.p1.x + this.p2.x;
		let ay = this.p0.y - 2 * this.p1.y + this.p2.y;
		let bx = 2 * this.p1.x - 2 * this.p0.x;
		let by = 2 * this.p1.y - 2 * this.p0.y;

		this.A = 4 * (ax * ax + ay *ay);
		this.B = 4 * (ax * bx + ay *by);
		this.C = bx * bx + by * by;
		
		this.points.length = 0;
		let totalLength = this.length(1);
		
		for (let index = 1; index < this.step; index++) {  
			let t = index / this.step;
			
			if(this.uniformSpeed) {
				//根据 L 函数的反函数,求得 l 对应的 t 值
				t = this.invertLength(t, totalLength*t);
			}
			
			let x = (1-t)*(1-t)*this.p0.x+2*(1-t)*t*this.p1.x+t*t*this.p2.x;
			let y = (1-t)*(1-t)*this.p0.y+2*(1-t)*t*this.p1.y+t*t*this.p2.y;
			
			this.points.push({x:x, y:y});
		}
	}
	
	draw() {
		this.points.forEach(pt => {
			fill('green');
			ellipse(pt.x, pt.y, 5, 5);
		});
	}
}

End

`,3))])}const k2=l(e,[["render",u2],["__file","BezierLine.html.vue"]]),f2=JSON.parse('{"path":"/blog/2025/03/BezierLine.html","title":"匀速贝塞尔曲线运动的实现","lang":"zh-CN","frontmatter":{"title":"匀速贝塞尔曲线运动的实现","tags":"程序 算法"},"headers":[{"level":2,"title":"End","slug":"end","link":"#end","children":[]}],"git":{"contributors":[{"name":"thejinchao","username":"thejinchao","email":"thejinchao@gmail.com","commits":1,"url":"https://github.com/thejinchao"}]},"filePathRelative":"blog/2025/03/BezierLine.md"}');export{k2 as comp,f2 as data};