惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Martin Fowler
Martin Fowler
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
罗磊的独立博客
Apple Machine Learning Research
Apple Machine Learning Research
The Cloudflare Blog
L
LangChain Blog
博客园 - 司徒正美
G
Google Developers Blog
博客园 - 【当耐特】
GbyAI
GbyAI
月光博客
月光博客
人人都是产品经理
人人都是产品经理
D
DataBreaches.Net
大猫的无限游戏
大猫的无限游戏
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
V
Visual Studio Blog
D
Docker
MongoDB | Blog
MongoDB | Blog
Vercel News
Vercel News
Stack Overflow Blog
Stack Overflow Blog
Jina AI
Jina AI
博客园 - 聂微东

博客园 - 遗忘海岸

简协运动模拟 电磁场中的运动轨迹模拟 圆周运动模拟 带阻力的平抛运动 C# 队列的一些并发模拟 devexpress gridview master,detail视图 focuseRowHandle 同步选中 C# Tcp Server端实现,使用TcpListener 深信服务超融合管理Api调用 GDI+画工作流图的一些总结 GDI+画直线带箭头 devexpress schedulerControl Gantt View 使用 逻辑回归损失函数求导 matplotlim柱状图 匀加速运动模拟python,(matplotlib) C# 实现排列 python 类鸟群Boids C#动态编译 正太分布数据排序后分段数据的方差与标准差 Android 的一个通用列表单选AlertDialog封装
绘制贝塞而曲线
遗忘海岸 · 2024-05-16 · via 博客园 - 遗忘海岸

辅助函数

        private Pen redPen = new Pen(Color.Red, 2);

        public static PointF Multi(Point p, float fac)
        {
            var pf = new PointF();
            pf.X = p.X * fac;
            pf.Y = p.Y * fac;
           
            return pf;
        }
        public static PointF Adds(params PointF[] ps)
        {
            var pf = new PointF();
            foreach (var it in ps)
            {
                pf.X += it.X;
                pf.Y += it.Y;
            }
            return pf;
        }
        public static float Pow(double v, double n)
        {
            return (float)Math.Pow(v,n);
        }

View Code

按参数方程计算点

                var p0 = new Point(180, 10);
                var p1 = new Point(140, 30);
                var p2 = new Point(180, 360);
                var p3 = new Point(150, 400);
                //dc.DrawBezier(redPen, p0,p1,p2,p3);

                
                var points4Bezier = new PointF[100];
                for (int i = 0; i < 100; i++)
                {
                    var t=0.01 * i;
                    var p =Adds(
                        Multi(p0, Pow((1 - t), 3)) , 
                        Multi(p1, 3f * (float)t * Pow((1 - t),2) ) , 
                        Multi(p2, Pow(t, 2) * 3f * (float)(1 - t)) , 
                        Multi(p3, Pow(t, 3)) 
                        );
                    points4Bezier[i] = p;
                }
                dc.DrawCurve(redPen, points4Bezier);

View Code