现在让我们再次重写矩阵方程: M * A = B 其中 M 是您的 8x8 矩阵, A =(a3,a2,a1,a0,b3,b2,b1,b0)和 B =(1,5,5,4,0,0,0,0)您可以这样解决: inverse(M)* M * A =逆(M)* BA =逆(M)* B 因此,您将获得 A ,其中保存了 B 的 p1,p2 多项式系数,从而保存了您的位置( y 一次通过坐标,x一次通过x坐标),所以得到了 p1x,p1y,p2x,p2y 多项式.插值需要哪一个.但是,这种方法有点落后,通常使用预定义的多项式形式,例如SPLINE,BEZIER,具有定义的属性,例如连续性,线性等(不需要逆矩阵运算).但是,如果您需要像本例中那样的自定义属性,则没有太多选择.有关更多信息,请参见如何生成多点线性插值? I read the article on https://www.value-at-risk.net/cubic-spline-interpolation/I understand all but I don't know how I can get the values for the matrix:I know that there is something like hi = hi+1 - hiI visited several websites, read different explenations, but I never found out how exactly I come to this values in the matrix. 解决方案 The matrix is just system of equations encoded as matrix so it can be easily computed by inverse matrix.For example second line of matrix (8,4,2,1,0,0,0,0) after matrix multiplication means this:a3.2^3+a2.1^2+a1.2^1+a0=5which is your p1(2)=5 the lines are:p1(1)=1p1(2)=5p2(2)=5p2(3)=4p1'(2)-p2'(2)=0p1''(2)-p2''(2)=0p1''(1)=0p2''(3)=0so for example last matrix line ( 0,0,0,0,18,2,0,0 ) is this:b3.18 + b2.2 = 0If we derive p2(t) up to 2-nd derivationp2(t) = b3.t^3 + b2.t^2 + b1.t + b0p2'(t) = 3.b3.t^2 + 2.b2.t + b1p2''(t) = 2.3.b3.t + 1.2.b2 = 6.b3.t + 2.b2Now for t=3 we get:p2''(3) = 6.b3.3 + 2.b2 = 18.b3 + 2.b2And encoded into matrix (last line)(0,0,0,0,18,2,0,0) * ( a3,a2,a1,a0,b3,b2,b1,b0) = 0Which matches your example. Hope it is clear now ...Beware this example of yours is just for y axis as you got 2D curve you need to do this for x axis in the same manner again ...Now let rewrite the matrix equation again:M*A=BWhere M is your 8x8 matrix, A=(a3,a2,a1,a0,b3,b2,b1,b0) and B=(1,5,5,4,0,0,0,0) you can solve this like this:inverse(M)*M*A = inverse(M)*B A = inverse(M)*BSo you obtain the A which holds your p1,p2 polynomials coefficients for B which holds your position (y coordinates in one pass and x coordinates in the next) so you got p1x,p1y,p2x,p2y polynomials. Which is what you need for the interpolation. However this approach is a bit backward and usually predefined polynomial forms are used like SPLINE,BEZIER with defined properties like continuity, linearity, etc (no need for inverse matrix operation). But if you need custom properties like in this example then you do not have much of a choice.For more info see How can i produce multi point linear interpolation? 这篇关于计算三次样条插值中的矩阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-24 15:12