样条之CatmullRom
所谓样条曲线是指给定一组控制点而得到一条曲线,曲线的大致形状由这些点予以控制,一般可分为插值样条和逼近样条两种,插值样条通常用于数字化绘图或动画的设计,逼近样条一般用来构造物体的表面。CatmullRom样条与上一节所讲的B样条很相似,不同在于CatmullRom样条的曲线会经过其每一个控制点。
The centripetal Catmull–Rom is a subclass of cubic Hermite spline that extends the Catmull–Rom implementation by allowing each of the four control points to be associated with an arbitrary time interval in the computation of a value on the curve. This modifies the behavior of the curve. The curve is an interpolation, and will intersect with all but the first and last control points. If the time intervals are uniform, the result will be the same as that of the original Catmull–Rom spline curve. The chordal curve uses the two dimensional Euclidean distance between control points to provide the time elements, while the centripetal curve uses the square root of the Euclidean distance. The principal reason for using the centripetal version is that it has been shown to be free of cusps and self-intersections.
关于插值与样条的介绍请看:http://www.cnblogs.com/WhyEngine/p/4020294.html
核心代码:
void YcCatmullRomSpline::BuildWeights()
{
ClearWeights(); for (Yuint i = ; i < ; i++)
{
m_splineWeights[i] = (Yreal*)malloc((m_subD)*sizeof(Yreal));
m_tangentWeights[i] = (Yreal*)malloc((m_subD)*sizeof(Yreal));
} Yreal u, u_2, u_3;
for (Yuint i = ; i < m_subD; i++)
{
u = (float)i / m_subD;
u_2 = u * u;
u_3 = u_2 * u; // 参见"游戏编程精粹1"P333
m_splineWeights[][i] = (-1.0f*u_3 + 2.0f*u_2 - 1.0f*u + 0.0f)*0.5f;
m_splineWeights[][i] = ( 3.0f*u_3 - 5.0f*u_2 + 0.0f*u + 2.0f)*0.5f;
m_splineWeights[][i] = (-3.0f*u_3 + 4.0f*u_2 + 1.0f*u + 0.0f)*0.5f;
m_splineWeights[][i] = ( 1.0f*u_3 - 1.0f*u_2 + 0.0f*u + 0.0f)*0.5f; m_tangentWeights[][i] = (-3.0f*u_2 + 4.0f*u - 1.0f)*0.5f;
m_tangentWeights[][i] = ( 9.0f*u_2 - 10.0f*u + 0.0f)*0.5f;
m_tangentWeights[][i] = (-9.0f*u_2 + 8.0f*u + 1.0f)*0.5f;
m_tangentWeights[][i] = ( 3.0f*u_2 - 2.0f*u + 0.0f)*0.5f;
}
}
切图:


相关软件的下载地址为:http://files.cnblogs.com/WhyEngine/TestSpline.zip
样条之CatmullRom的更多相关文章
- GDI+编程说明及小结
原文地址:http://blog.csdn.net/byxdaz/article/details/5972759 GDI+(Graphics Device Interface Plus图形设备接口加) ...
- GDI+编程小结
GDI+(Graphics Device Interface Plus图形设备接口加)是Windows XP和Windows Server 2003操作系统的子系统,也是.NET框架的重要组成部分,负 ...
- 样条之埃尔米特(Hermite)
埃尔米特(Charles Hermite,1822—1901) 法国数学家.巴黎综合工科学校毕业.曾任法兰西学院.巴黎高等师范学校.巴黎大学教授.法兰西科学院院士.在函数论.高等代数.微分方程等方面都 ...
- B样条基函数的定义和性质
定义:令U={u0,u1,…,um}是一个单调不减的实数序列,即ui≤ui+1,i=0,1,…,m-1.其中,ui称为节点,U称为节点矢量,用Ni,p(u)表示第i个p次(p+1阶)B样条基函数,其定 ...
- B样条基函数(cubic spline basis)
B样条基函数用作权重 reference http://blog.csdn.net/tuqu
- [图形学] Chp14 GLU曲面裁剪函数程序示例及样条表示遗留问题
样条表示这章已经看完,最后的GLU曲面裁剪函数,打算按书中的示例实现一下,其中遇到了几个问题. 先介绍一下GLU曲面裁剪函数的使用方法. 1 裁剪函数是成对出现的: gluBeginTrim和gluE ...
- [摘抄] Bezier曲线、B样条和NURBS
Bezier曲线.B样条和NURBS,NURBS是Non-Uniform Rational B-Splines的缩写,都是根据控制点来生成曲线的,那么他们有什么区别了?简单来说,就是: Bezier曲 ...
- B样条基函数的定义及系数的意义
原文链接:http://blog.csdn.net/tuqu/article/details/5177405 贝塞尔基函数用作权重.B-样条基函数也一样:但更复杂.但是它有两条贝塞尔基函数所没有的特性 ...
- 样条之拉格朗日Lagrange(一元全区间)插值函数
这是使用拉格朗日插值函数生成的样条曲线.在数值分析中,拉格朗日插值法是以法国十八世纪数学家约瑟夫·拉格朗日命名的一种多项式插值方法.许多实际问题中都用函数来表示某种内在联系或规律,而不少函数都只能通过 ...
随机推荐
- sublime安装package control 的方法
1.安装sublime3后,点击菜单 view>show console,复制以下代码按回车即可,安装时稍微有些卡,需要耐心等待. import urllib.request,os; pf = ...
- 使用Maven搭建Struts2框架的开发环境
一.创建基于Maven的Web项目
- php版本CKFinder3.4.4自定义上传文件位置
1.修改文件上传路径: 编辑ckfinder目录下config.php,70行设置为: 'baseUrl' => '/uploads/'.date('Ymd').'/'; 这样上 ...
- 安装 intelliJ idea 。 快速学会kotlin
用户界面主题 - 默认插件-功能插件 调整 idea 到你的任务 idea 有 许多 工具 可用 通过 默认. 你能够设置 你需要的. 跳过 剩下的 设置默认 . 回到 用户界面主题. 下一步:功能插 ...
- BZOJ.3680.吊打XXX(模拟退火/爬山算法)
题目链接 一个比较好的解释? 模拟退火(Simulated Annealing,SA): (1)初始化一个温度(充分大).初始解状态S.每个T值的迭代次数. (2)对i=1,...,L,做(3)至(7 ...
- php7 & lua 压测对比
内存:32G CPU:2个6核 接口数据deflate 压缩后 均不到10k, ==== php7 ==== Concurrency Level: 100 Time taken for tests: ...
- [Java]类的生命周期(上)类的加载和连接[转]
本文来自:曹胜欢博客专栏.转载请注明出处:http://blog.csdn.net/csh624366188 类加载器,顾名思义,类加载器(class loader)用来加载 Java 类到 Java ...
- 一些收集的MikroTik RouterOS破解版虚拟机VMware
会不定期更新,也许后续自己来做,现在是收集.持续关注这个分享链接即可. 链接:https://pan.baidu.com/s/1j7ciesPm1yAgCJ26dLJ8sg 密码:i64w
- js获取鼠标点击事件的相对位置
<html><head><title>位置</title><script language="javascript" type ...
- 解决 PermGen space Tomcat内存设置(转)
在使用Java程序从数据库中查询大量的数据或是应用服务器(如tomcat.jboss,weblogic)加载jar包时会出现java.lang.OutOfMemoryError异常.这主要是由于应用服 ...