所谓样条曲线是指给定一组控制点而得到一条曲线,曲线的大致形状由这些点予以控制,一般可分为插值样条和逼近样条两种,插值样条通常用于数字化绘图或动画的设计,逼近样条一般用来构造物体的表面。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的更多相关文章

  1. GDI+编程说明及小结

    原文地址:http://blog.csdn.net/byxdaz/article/details/5972759 GDI+(Graphics Device Interface Plus图形设备接口加) ...

  2. GDI+编程小结

    GDI+(Graphics Device Interface Plus图形设备接口加)是Windows XP和Windows Server 2003操作系统的子系统,也是.NET框架的重要组成部分,负 ...

  3. 样条之埃尔米特(Hermite)

    埃尔米特(Charles Hermite,1822—1901) 法国数学家.巴黎综合工科学校毕业.曾任法兰西学院.巴黎高等师范学校.巴黎大学教授.法兰西科学院院士.在函数论.高等代数.微分方程等方面都 ...

  4. B样条基函数的定义和性质

    定义:令U={u0,u1,…,um}是一个单调不减的实数序列,即ui≤ui+1,i=0,1,…,m-1.其中,ui称为节点,U称为节点矢量,用Ni,p(u)表示第i个p次(p+1阶)B样条基函数,其定 ...

  5. B样条基函数(cubic spline basis)

    B样条基函数用作权重 reference http://blog.csdn.net/tuqu

  6. [图形学] Chp14 GLU曲面裁剪函数程序示例及样条表示遗留问题

    样条表示这章已经看完,最后的GLU曲面裁剪函数,打算按书中的示例实现一下,其中遇到了几个问题. 先介绍一下GLU曲面裁剪函数的使用方法. 1 裁剪函数是成对出现的: gluBeginTrim和gluE ...

  7. [摘抄] Bezier曲线、B样条和NURBS

    Bezier曲线.B样条和NURBS,NURBS是Non-Uniform Rational B-Splines的缩写,都是根据控制点来生成曲线的,那么他们有什么区别了?简单来说,就是: Bezier曲 ...

  8. B样条基函数的定义及系数的意义

    原文链接:http://blog.csdn.net/tuqu/article/details/5177405 贝塞尔基函数用作权重.B-样条基函数也一样:但更复杂.但是它有两条贝塞尔基函数所没有的特性 ...

  9. 样条之拉格朗日Lagrange(一元全区间)插值函数

    这是使用拉格朗日插值函数生成的样条曲线.在数值分析中,拉格朗日插值法是以法国十八世纪数学家约瑟夫·拉格朗日命名的一种多项式插值方法.许多实际问题中都用函数来表示某种内在联系或规律,而不少函数都只能通过 ...

随机推荐

  1. 015.Zabbix的日志监控配置

    一 日志监控概述 Zabbix可用于集中监控和分析日志,支持有日志轮询的日志监控分析.当日志中出现相关警告信息(如警告.报错等),可以发送通知给用户.日志监控功能,必须满足以下两个条件: Zabbix ...

  2. [转]状态压缩dp(状压dp)

    状态压缩动态规划(简称状压dp)是另一类非常典型的动态规划,通常使用在NP问题的小规模求解中,虽然是指数级别的复杂度,但速度比搜索快,其思想非常值得借鉴. 为了更好的理解状压dp,首先介绍位运算相关的 ...

  3. 第二届i春秋挖洞大赛的一些感想

    挖洞比赛嘛,根据规则就是一个问题,如何在短时间内挖到更多.等级更高的漏洞? 先分析这个问题,需求是什么? 更多? 等级更高? 短时间内? 首先要解决的是时间的问题 时间有限,所以你必须要快.如何快?把 ...

  4. Home Assistant + 树莓派:强大的智能家居系统 · 设备接入篇

    转载:Home Assistant + 树莓派:强大的智能家居系统 · 设备接入篇 目录 HASS 配置框架 主文件设置 Homebridge 设置 鹬蚌相争? 设备追踪设置 更新日志 作者的话 相信 ...

  5. Android 前台服务

    Android 前台服务 学习自 https://blog.csdn.net/guolin_blog/article/details/11952435#t3 前台服务漫谈 我们之前学习的Service ...

  6. bzoj 3673 可持久化并查集

    本质上是维护两个可持久化数组,用可持久化线段树维护. /************************************************************** Problem: ...

  7. 接口开发-集成数据库操作(mybatis)

    关于数据存储,最常用的方式就是存到数据库,此篇以MySQL数据库为例,以mybatis框架完成数据库的操作. 一.添加对应依赖 <!-- 数据库:MySQL --> <depende ...

  8. How to add Leading Zeroes to a Number (Delphi Format)

    How to add Leading Zeroes to a Number (Delphi Format) Here's how convert (an integer) number to a st ...

  9. OpenOCD Debug Adapter Configuration

    Correctly installing OpenOCD includes making your operating system give OpenOCD access to debug adap ...

  10. [译] Go 并发编程基础

    原文:Fundamentals of concurrent programming 译者:youngsterxyf 本文是一篇并发编程方面的入门文章,以Go语言编写示例代码,内容涵盖: 运行期并发线程 ...