SVG路径和de Casteljau的算法给出不同的结果WPF

问题描述

我在 WPF 上实现了 de Casteljau 的算法,它看起来很适合切点(红色矩形)

enter image description here

但我发现它给出了不同的结果

M 149,256 C 149,198 195,149 256,150 326,150 370,196 370,256 371,317 328,366 256,366 190,365 147,313 149,256 Z

enter image description here

enter image description here

所以我有什么想念的吗?

public List<MyLines> Calc2(double t,List<MyLines> lines_ = null)
        {
            bool first = false;

            if (lines_ == null)
            {
                lines_ = lines;
                first = true;
            }

            if (lines.Count == 0)
                return lines;
            else if (lines_.Count == 1)
            {
                var tmp = new MyLines();
                tmp.x1 = tmp.x2 = (1 - t) * lines_[0].x1 + t * lines_[0].x2;
                tmp.y1 = tmp.y2 = (1 - t) * lines_[0].y1 + t * lines_[0].y2;
                TangentPoint = new MyPoint() { x = tmp.x2,y = tmp.y2 };
                return new List<MyLines>() { tmp };
            }

            List<MyLines> Res_lines = new List<MyLines>();
            for (int i = 0; i < lines_.Count - 1; i++)
            {
                double X1 = (1 - t) * lines_[i].x1 + t * lines_[i].x2;
                double Y1 = (1 - t) * lines_[i].y1 + t * lines_[i].y2;

                double X2 = (1 - t) * lines_[i + 1].x1 + t * lines_[i + 1].x2;
                double Y2 = (1 - t) * lines_[i + 1].y1 + t * lines_[i + 1].y2;

                Res_lines.Add(new MyLines() { x1 = X1,x2 = X2,y1 = Y1,y2 = Y2,id=id_++});
            }

            if (Res_lines.Count == 1)
                TangentLine = Res_lines[0];
            
            Res_lines.AddRange(Calc2(t,Res_lines));
            return Res_lines;
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)