所谓样条曲线是指给定一组控制点而得到一条曲线,曲线的大致形状由这些点予以控制,一般可分为插值样条和逼近样条两种,插值样条通常用于数字化绘图或动画的设计,逼近样条一般用来构造物体的表面。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. JAVAEE——SpringBoot入门:简介、微服务、环境准备、helloworld与探究、快速构建项目

    一.Spring Boot 入门 1.Spring Boot 简介 简化Spring应用开发的一个框架: 整个Spring技术栈的一个大整合: J2EE开发的一站式解决方案: 2.微服务 2014,m ...

  2. 【Ray Tracing in One Weekend 超详解】 光线追踪1-7 Dielectric 半径为负,实心球体镂空技巧

    今天讲这本书最后一种材质 Preface 水,玻璃和钻石等透明材料是电介质.当光线照射它们时,它会分裂成反射光线和折射(透射)光线. 处理方案:在反射或折射之间随机选择并且每次交互仅产生一条散射光线 ...

  3. ABP-Zero模块

    一.介绍 二.启动模版 三.功能 1,租户管理 2,版本管理 3,用户管理 4,角色管理 5,组织单位管理 6,权限管理 7,语言管理 8,Identity Server集成 一.介绍 1,Zero模 ...

  4. 7、Redis中对ZSet类型的操作命令

    写在前面的话:读书破万卷,编码如有神 --------------------------------------------------------------------   ---------- ...

  5. Codeforces Round #374 (Div. 2) B. Passwords 贪心

    B. Passwords 题目连接: http://codeforces.com/contest/721/problem/B Description Vanya is managed to enter ...

  6. 解决Windows x86网易云音乐不能将音乐下载到SD卡的BUG

    由于我个人最常用的电脑是Surface pro4 256G版本,装了不少生产力空间还挺吃紧的,音乐之类的必然都存单独的SD卡里.用UWP版本的网易云音乐倒是没问题,最近问题来了,UWP版本的网易云音乐 ...

  7. Android应用程序模型:应用程序,任务,进程,线程

    大多数操作系统,在应用程序所寄存的可执行程序映像(如Windows系统里的.exe).它所运行的进程以及和用户交互的图标和应用之间有一种严格的1对1关系.在Android系统里,这些关联要松散得多.并 ...

  8. Windows Server 2008 r2 64位激活

    1.工具:CW 下载链接:https://pan.baidu.com/s/1bphOkW3 密码:80d4 2.查看系统是否激活:计算机图标点右键,选择 属性,就可以查看激活情况 3.准备好CW工具 ...

  9. [golang 易犯错误] golang 局部变量初始化:=的陷阱

    我们知道,golang中局部变量初始化方法(使用“:=”创建并赋值),让我们在使用变量时很方便.但是,这也是易犯错误的地方之一.特别是这个初始化符还支持多个变量同时初始化,更特别的是它还支持原有变量赋 ...

  10. TCP套接字端口复用SO_REUSEADDR

    下面建立的套接字都是tcp套接字 1.进程创建监听套接字socket1,邦定一个指定端口,并接受了若干连接.那么进程创建另外一个套接口socket2,并试图邦定同一个端口时候,bind错误返回“Add ...