当前位置: 首页 > news >正文

C++ C# 贝塞尔曲线

二阶贝塞尔曲线公式

 三阶贝塞尔曲线公式

C++ 三维坐标点  二阶到N阶源码

//二阶公式:
FVector BezierUtils::CalculateBezierPoint(float t, FVector startPoint, FVector controlPoint, FVector endPoint)
{float t1 = (1 - t) * (1 - t);float t2 = 2 * t * (1 - t);float t3 = t * t;return t1 * startPoint + t2 * controlPoint + t3 * endPoint;
}// 三阶贝塞尔曲线
FVector BezierUtils::BezierCurve(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
{Vector3 B = Vector3.zero;float t1 = (1 - t) * (1 - t) * (1 - t);float t2 = 3 * t * (1 - t) * (1 - t);float t3 = 3 * t * t * (1 - t);float t4 = t * t * t;return t1 * p0 + t2 * p1 + t3 * p2 + t4 * p3;
}/// n阶贝塞尔曲线
FVector BezierUtils::BezierCurve(List<FVector3> pointList, float t)
{FVector B = FVector(0,0,0);if (pointList == null){return B;}if (pointList.Count < 2){return pointList[0];}List<Vector3> tempPointList = new List<Vector3>();for (int i = 0; i < pointList.Count - 1; i++){Vector3 tempPoint = BezierCurve(pointList[i], pointList[i + 1], t);tempPointList.Add(tempPoint);}return BezierCurve(tempPointList, t);
}

C# 三维坐标点  二阶到N阶源码

using UnityEngine;
using System.Collections.Generic;/// <summary>
/// 贝塞尔工具类
/// </summary>
public static class BezierUtils
{/// <summary>/// 线性贝塞尔曲线/// </summary>public static Vector3 BezierCurve(Vector3 p0, Vector3 p1, float t){Vector3 B = Vector3.zero;B = (1 - t) * p0 + t * p1;return B;}/// <summary>/// 二阶贝塞尔曲线/// </summary>public static Vector3 BezierCurve(Vector3 p0, Vector3 p1, Vector3 p2, float t){Vector3 B = Vector3.zero;float t1 = (1 - t) * (1 - t);float t2 = 2 * t * (1 - t);float t3 = t * t;B = t1 * p0 + t2 * p1 + t3 * p2;return B;}/// <summary>/// 三阶贝塞尔曲线/// </summary>public static Vector3 BezierCurve(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t){Vector3 B = Vector3.zero;float t1 = (1 - t) * (1 - t) * (1 - t);float t2 = 3 * t * (1 - t) * (1 - t);float t3 = 3 * t * t * (1 - t);float t4 = t * t * t;B = t1 * p0 + t2 * p1 + t3 * p2 + t4 * p3;return B;}/// <summary>/// n阶贝塞尔曲线/// </summary>public static Vector3 BezierCurve(List<Vector3> pointList, float t){Vector3 B = Vector3.zero;if (pointList == null){return B;}if (pointList.Count < 2){return pointList[0];}List<Vector3> tempPointList = new List<Vector3>();for (int i = 0; i < pointList.Count - 1; i++){Vector3 tempPoint = BezierCurve(pointList[i], pointList[i + 1], t);tempPointList.Add(tempPoint);}return BezierCurve(tempPointList, t);}
}

http://www.lryc.cn/news/348897.html

相关文章:

  • 勒索软件漏洞?在不支付赎金的情况下解密文件
  • 实时“秒回”,像真人一样语音聊天,GPT-4o模型强到恐怖
  • Properties配置文件和源码
  • redis原生命令及项目使用
  • 使用VSCode生成代码、查询数据表
  • 使用 PXE+Kickstart 批量网络自动装机
  • 微信小程序交互增强:实现上拉加载、下拉刷新与一键返回顶部【代码示例】
  • leetcode刷题指南
  • hadoop学习---基于Hive的数据仓库相关函数机制及其优化方案
  • 【MySQL数据库】丨高可用之MHA集群部署
  • uniapp的底部弹出层实现保姆式教程
  • 国外IP代理免费试用技巧
  • vue-cropper裁剪图片 vue
  • 算法-卡尔曼滤波之基本数学的概念
  • NeoVim配置文件基本的
  • Qt学习笔记1.3.4 QtCore-Qt资源系统
  • 同城组局同城活动找搭子小程序JAVA源码面芽组局的实现方案
  • Unable to locate the .NET SDK
  • C++STL初阶(1):string的使用及初阶原理
  • Day41-Java基础之反射和动态代理
  • Tomcat的实现
  • RK3576 Camera:资源介绍
  • Symfony DomCrawler库在反爬虫应对中的应用
  • 1Panel应用推荐:Uptime Kuma
  • 传输文件协议FTP与LFTP
  • expdp和impdp 实战
  • 知了汇智引领未来:全新AIGC系列课程,打造数字时代人才新标杆
  • 软件项目验收第三方测试报告如何获取
  • linux下脚本监控mysql主从同步异常时发邮件通知
  • 【MySQL】分组排序取每组第一条数据