本文介绍了3点参数插值曲线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我想绘制一个3点参数样条曲线,如本网页所示。这不是一个贝塞尔曲线。积分必须都在曲线上。 http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/Parametrics.html 我需要两个同时的方程式,x和y有一个公共变量(t = 0-1)。不知道如何用数学创造它们。任何帮助,将不胜感激。谢谢。I would like to draw a 3 point parametric spline as demonstrated at this webpage. This is not a bezier curve. The points must all be on the curve."http://www.doc.ic.ac.uk/~dfg/AndysSplineTutorial/Parametrics.html"I need two simultanious equations, x and y with a common variable(t = 0-1). Don''t know how to create them from the mathematics. Any help would be appreciated. thanks.推荐答案P(0)={x0,y0}={a0,b0};P(s)={xs,ys}={a2*s*s+a1*s+a0, b2*s*s+b1*s+b0}P(1)={x1,y1}={a2+a1+a0, b2+b1+b0} 其中P(0),P(s),P(1)是已知(0< s< 1)。 我们必须找到六个参数 a2,a1,a0,b2,b1,b0 。将计算限制为 x (y是相同的):Where the P(0), P(s), P(1) are known (0<s<1).We have to find the six parameters a2,a1,a0, b2,b1,b0. Limiting computation to x (y is the same):x0 = a0x1 = a2+a1+x0 => a1 = x1-x0-a2xs = a2*s*s+x1*s-x0*s-a2*s+x0 => a2 = (xs-x0+(x0-x1)*s)/(s-s*s) a2 使用第二个等式计算 a1 的值。 现在 a2,a1,a0 (并且以相同的方式 b2,b1,b0 )已知并且您可以计算 P(t)= {x(t),y(t )} = {a2 * t * t + a1 * t + a0,b2 * t * t + b1 * t + b0} 每个 0< t< 1 。 (我希望它是正确的......)With a2 value you compute a1 using the second equation.Now a2,a1,a0 (and in the same way b2,b1,b0) are known and you may compute P(t) = {x(t), y(t)} = {a2*t*t+a1*t+a0, b2*t*t+b1*t+b0} for each 0<t<1.(I hope it is correct...)class Formula{ private Point a0; private Point a1; private Point a2; private Point A(Point p0, Point p1, Point p2, double t1) { return p0; } private Point B(Point p0, Point p1, Point p2, double t1) { double d = 1/((1-t1)*t1); return (p1-p0)*d; } private Point C(Point p0, Point p1, Point p2, double t1) { return d = 1/(1-t1); return (p2-p0)*d; } public Formula(Point p0, Point p1, point p2, double t1) { Point a = A(p0, p1, p2, t1); Point b = B(p0, p1, p2, t1); Point c = C(p0, p1, p2, t1); a0 = a; a1 = b-c*t1; a2 = c-b; } public Point P(double t) { return ((a2*t)+a1)*t+a0; }}...var start = new Point(0,2); // p0var end = new Point(7,6); // p2var p1 = new Point(2,3); // p1double t1 = 0.5;var Formula curve = new Formula(start, p1, end, t1);...int steps = 100;double step = 1.0/(double)steps;Point curr = p0;foreach(int i = 1; i <= steps; ++i){ Point next = curve.P(step*(double)i); Draw(curr, next); curr = next;} 干杯 AndiCheersAndi 这篇关于3点参数插值曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-21 05:41