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

    安装redis时候的坑 随手记录一下,以此为借鉴. 1.按照需求下载redis服务 redis可视化文件 2.安装及环境搭建 修改服务里redis.windows-service.conf文件,或者r ...

  2. Ajax json交互和SpringMVC中@RequestBody

    Ajax json交互和SpringMVC中@RequestBody 标签: 背景 自己提供出去得接口中参数设置为@RequestBody VipPromotionLog vipPromotionLo ...

  3. 2,EasyNetQ-日志记录

    EasyNetQ提供了一个IEasyNetQLogger接口: public interface IEasyNetQLogger { void DebugWrite(string format, pa ...

  4. Shape流动效果

    <Window x:Class="MvvmLight1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/ ...

  5. Linux下实现自动设置SSH代理

    SSH的巨大价值体现在能够配置为代理服务器上.不像在Windows下每次还需要手动登录设置,Linux有很好的工具链能够实现自动设置SSH代理,就是expect和ssh的联合使用,再加上proxych ...

  6. Codeforces Round #369 (Div. 2) C. Coloring Trees 动态规划

    C. Coloring Trees 题目连接: http://www.codeforces.com/contest/711/problem/C Description ZS the Coder and ...

  7. Mysql update case

    UPDATE table SET total = CASE WHEN total = '1' THEN total- 1 ELSE total = '2' END WHERE id = 17

  8. js识别用户设备是移动端手机时跳转到手机网站

    一.识别到用户的设备是手机等移动端设备时跳转到移动端网站 var mobileAgent = new Array("iphone", "ipod", " ...

  9. 正余弦信号的DFT频谱分析

    一般的,对正余弦信号进行採样并DFT运算,画出频谱图,会发现频谱并不干净.这样的现象称为频谱泄漏.由于DFT运算仅仅能是有限序列,突然的截断产生了泄漏. 会有这种特殊情况.当採样截取的刚好是整数个周期 ...

  10. 找不到包含 OwinStartupAttribute 的程序集

    配置一个 MVC 项目时 遇到的  vs 2013 解决办法:在 webconfig 中 <appSettings> <add key="owin:AutomaticApp ...