如何创建使用XAML一个简单的2D NURBS? [英] How can I create a simple 2D NURBS using XAML?

查看:130
本文介绍了如何创建使用XAML一个简单的2D NURBS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个样条曲线有两个端点和N的控制点。
据我所知,贝塞尔曲线,只允许一个控制点,并Bezier样条线允许两个控制点。不过,我需要能够因为我认为合适的,并不局限于一个或两个添加尽可能多的控制点。

下面是我想要实现的,有4个控制点的例子:
(来源: NURBS曲面维基百科的文章)

到目前为止,我只能够一系列BezierSegments的结合在了一起这样的:

 <折线行程=绿色拉伸=制服
            点数=0,0 1,2 2,1 3,3 4,3 5,2 6,3 7,2 8,1.75 9,2.5/>

<路径行程=红拉伸=制服>
  < Path.Data>
    <的PathGeometry>
      < PathGeometry.Figures>
        < PathFigureCollection>
          <的PathFigure StartPoint可以=0,0>
            < PathFigure.Segments>
              < PathSegmentCollection>
                < BezierSegment点1 =1,2点2 =2,1POINT3 =3,3/>
                < BezierSegment点1 =4,3点2 =5,2POINT3 =6,3/>
                < BezierSegment点1 =7,2点2 =8,1.75POINT3 =9,2.5/>
              < / PathSegmentCollection>
            < /PathFigure.Segments>
          < /的PathFigure>
        < / PathFigureCollection>
      < /PathGeometry.Figures>
    < /的PathGeometry>
  < /Path.Data>
< /路径>
 

解决方案

不开箱即用,但看看的这previous 质疑它会指向你如何使用C#绘制NURBS,你可以再打开code到的东西然后实现的 PathSegment 以用它WPF下。

I need to create a spline with two endpoints and 'n' control points.
As far as I am aware, a Bezier curve allows for only one control point, and a Bezier spline allows for two control points. However, I need to be able to add as many control points as I see fit, not limited to one or two.

Here is an example of what I want to achieve, with 4 control points:
(Source: Wikipedia article on NURBS)

So far I've only been able to combine a series of BezierSegments together like this:

<Polyline   Stroke="Green" Stretch="Uniform"
            Points="0,0 1,2 2,1 3,3 4,3 5,2 6,3 7,2 8,1.75 9,2.5" />

<Path Stroke="Red" Stretch="Uniform">
  <Path.Data>
    <PathGeometry>
      <PathGeometry.Figures>
        <PathFigureCollection>
          <PathFigure StartPoint="0,0">
            <PathFigure.Segments>
              <PathSegmentCollection>
                <BezierSegment Point1="1,2" Point2="2,1" Point3="3,3" />
                <BezierSegment Point1="4,3" Point2="5,2" Point3="6,3" />
                <BezierSegment Point1="7,2" Point2="8,1.75" Point3="9,2.5" />
              </PathSegmentCollection>
            </PathFigure.Segments>
          </PathFigure>
        </PathFigureCollection>
      </PathGeometry.Figures>
    </PathGeometry>
  </Path.Data>
</Path>

解决方案

Not out of the box but take a look at this previous question it will point you to how to draw NURBS using c#, you can then turn the code into something then implements PathSegment to used it under WPF.

这篇关于如何创建使用XAML一个简单的2D NURBS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆