给出轴坐标的NURBS曲线的点评估

时间:2015-06-25 07:58:05

标签: point expression-evaluation nurbs

我的问题是如何获得位于曲线上的点的第二个坐标(在2D中),该曲线在给定轴向坐标的情况下定义为NURBS曲线。我有结矢量,控制点,它们的权重和基函数。

我查看了类似的问题(How to find out Y coordinate of specific point in bezier curve in canvas?)但到目前为止找不到好的答案。 谢谢, 中号

1 个答案:

答案 0 :(得分:0)

如果您需要从头开始实施所有内容,这不是一件容易的事。不过,代码看起来像这样:

for each non-null knot interval in the knot vector of the NURBS
{
    extract Bezier curve B(t) from the NURBS for this knot interval [a, b];
    compute the minimum and maximum X values of the Bezier curve's control points. 
    if ( X0 is within [Xmin, Xmax] )
    {
        t0 = a;
        t1 = b;
        epsilon = 1.0e-06; // a small value;

       while ( (t1-t0) > epsilon )
       {
          Subdivide B(t) at t=0.5 to generate two Bezier curves: B1(t) and B2(t);
          compute the [Xmin1, Xmax1] for B1(t) and [Xmin2, Xmax2] for B2(t);
          if ( X0 is within [Xmin1, Xmax1] )
          {
              B(t) = B1(t);
              t0 = a;
              t1 = (a+b)/2;
          }  
          else
          {
              B(t) = B2(t);
              t0 = (a+b)/2;
              t1 = b;
          } 
       } // end while loop

       return ((t0+t1)/2);  // This is the parameter value you are looking for
   } // end if()

} // end for loop

(t0 + t1)/ 2是您要查找的参数值。请注意,如果X0值相同,您可能会找到多个解决方案。