一、埃尔米特插值算法简介

1.1 Charles Hermite

Charles Hermite was a noted 19th century French mathematician known for his work on number theory, quadratic forms, invariant theory, orthogonal polynomials, elliptic functions, and algebra. From the very beginning, he was more interested in advanced studies than in his curriculum, publishing two important papers while he was still in his secondary school. Later, he entered École Polytechnique to study mathematics but because of a deformity in his right feet, which required him to use a cane, he had to leave the academy the following year. He studied privately for five years and earned his baccalauréat and licence at the age of twenty-four. Meanwhile he started corresponding with eminent mathematicians, writing down his discoveries in the letters. Indeed, in spite of his phenomenal researches, he had few publications to his credit; circulating most his discoveries through letters, short notes and course lectures, which formed the basis of further research by other mathematicians. He was also a grand teacher, being appointed professor of analysis both in École Polytechnique and Sorbonne. In spite of his deformity, he was always in a happy mood, dividing his time between his family, teaching and research.

查尔斯·埃尔米特是19世纪著名的法国数学家,以其在数论、二次型、不变量理论、正交多项式、椭圆函数和代数方面的工作而闻名。从一开始,他就对高等教育比对课程更感兴趣,在中学时发表了两篇重要论文。后来,他进入理工学院学习数学,但由于右脚畸形,需要使用拐杖,他不得不在第二年离开学院。他私下学习了五年,并在二十四岁时获得了学士学位和执照。与此同时,他开始与著名的数学家通信,把自己的发现写在信中。事实上,尽管他进行了非凡的研究,但他几乎没有值得称赞的出版物;通过信件、短文和课程讲座传播他的大部分发现,这为其他数学家的进一步研究奠定了基础。他还是一位特级教师,被任命为理工学院和索邦大学的分析教授。尽管他有残疾,但他总是心情愉快,把时间分配在家庭、教学和研究之间。

1.2 Hermite curves

Hermite curves are very easy to calculate but also very powerful. They are used to smoothly interpolate between key-points (like object movement in keyframe animation or camera control). Understanding the mathematical background of hermite curves will help you to understand the entire family of splines. Maybe you have some experience with 3D programming and have already used them without knowing that (the so called kb-splines, curves with control over tension, continuity and bias are just a special form of the hermite curves).

埃尔米特曲线非常容易计算,但也非常强大。它们用于在关键点之间平滑插值(如关键帧动画或摄影机控制中的对象移动)。了解hermite曲线的数学背景将有助于您了解整个样条曲线族。也许你有一些3D编程的经验,并且在不知道的情况下已经使用过它们(所谓的kb样条,控制张力、连续性和偏差的曲线只是hermite曲线的一种特殊形式)。

To keep it simple we first start with some simple stuff. We also only talk about 2-dimensional curves here. If you need a 3D curve just do with the z-coordinate what you do with y or x. Hermite curves work in in any number of dimensions.
To calculate a hermite curve you need the following vectors:

  • P1: the startpoint of the curve
  • T1: the tangent (e.g. direction and speed) to how the curve leaves the startpoint
  • P2: he endpoint of the curve
  • T2: the tangent (e.g. direction and speed) to how the curves meets the endpoint

为了保持简单,我们首先从一些简单的东西开始。我们在这里也只讨论二维曲线。如果你需要一条三维曲线,只需使用z坐标,就像使用y或x一样。埃尔米特曲线可以在任何尺寸中工作。

要计算埃尔米特曲线,您需要以下向量:

P1:曲线的起点

T1:曲线离开起点的切线(例如方向和速度)

P2:曲线的端点

T2:曲线与端点相交的切线(例如方向和速度)

二、改进代码

using System;
using System.Drawing;
using System.Collections;
using System.Collections.Generic;namespace Zhou.CSharp.Algorithm
{/// <summary>/// 插值计算类Interpolation.cs/// 作者:周长发/// 改编:深度混淆/// https://blog.csdn.net/beijinghorn/// </summary>public static partial class Interpolation{/// <summary>/// 埃尔米特不等距插值/// </summary>/// <param name="x">一维数组,长度为n,存放给定的n个结点的值x(i),要求x(0)<x(1)<...<x(n-1)</param>/// <param name="y">一维数组,长度为n,存放给定的n个结点的函数值y(i),y(i) = f(x(i)), i=0,1,...,n-1</param>/// <param name="dy">一维数组,长度为n,存放给定的n个结点的函数导数值y'(i),y'(i) = f'(x(i)), i=0,1,...,n-1</param>/// <param name="t">存放指定的插值点的x值</param>/// <returns>指定的查指点t的函数近似值y=f(t)</returns>public static double Hermite(double[] x, double[] y, double[] dy, double t){int n = x.Length;double z = 0.0;// 循环插值for (int i = 1; i <= n; i++){double s = 1.0;for (int j = 1; j <= n; j++){if (j != i){s = s * (t - x[j - 1]) / (x[i - 1] - x[j - 1]);}}s = s * s;double p = 0.0;for (int j = 1; j <= n; j++){if (j != i){p = p + 1.0 / (x[i - 1] - x[j - 1]);}}double q = y[i - 1] + (t - x[i - 1]) * (dy[i - 1] - 2.0 * y[i - 1] * p);z = z + q * s;}return (z);}/// <summary>/// 埃尔米特等距插值/// (使用非等距插值的方法)/// </summary>/// <param name="x0">存放等距n个结点中第一个结点的值</param>/// <param name="step">等距结点的步长</param>/// <param name="y">一维数组,长度为n,存放给定的n个结点的函数值y(i),y(i) = f(x(i)), i=0,1,...,n-1</param>/// <param name="dy">一维数组,长度为n,存放给定的n个结点的函数导数值y'(i),y'(i) = f'(x(i)), i=0,1,...,n-1</param>/// <param name="t">存放指定的插值点的x值</param>/// <returns>指定的查指点t的函数近似值y=f(t)</returns>public static double Hermite(double x0, double step, double[] y, double[] dy, double t){double[] x = new double[y.Length];for (int i = 0; i < y.Length; i++, x0 += step){x[i] = x0;}return Hermite(x, y, dy, t);}
#if __OLD__/// <summary>/// 埃尔米特等距插值/// </summary>/// <param name="x0">等距n个结点中第一个结点的值</param>/// <param name="step">等距结点的步长</param>/// <param name="y">一维数组,长度为n,存放给定的n个结点的函数值y(i),y(i) = f(x(i)), i=0,1,...,n-1</param>/// <param name="dy">一维数组,长度为n,存放给定的n个结点的函数导数值y'(i),y'(i) = f'(x(i)), i=0,1,...,n-1</param>/// <param name="t">存放指定的插值点的x值</param>/// <returns>指定的查指点t的函数近似值y=f(t)</returns>public static double Hermite(double x0, double step, double[] y, double[] dy, double t){int n = y.Length;double z = 0.0;// 循环插值for (int i = 1; i <= n; i++){double s = 1.0;double q = x0 + (i - 1) * step;double p;for (int j = 1; j <= n; j++){p = x0 + (j - 1) * step;if (j != i){s = s * (t - p) / (q - p);}}s = s * s;p = 0.0;for (int j = 1; j <= n; j++){if (j != i){p = p + 1.0 / (q - (x0 + (j - 1) * step));}}q = y[i - 1] + (t - q) * (dy[i - 1] - 2.0 * y[i - 1] * p);z = z + q * s;}return (z);}
#endif}
}

POWER BY 315SOFT.COM

基于坐标点的计算,从点集计算插值曲线等拓展方法请参阅《拉格朗日插值算法及其拓展》

C#,码海拾贝(07)——埃尔米特(Hermite)曲线插值算法C#源程序相关推荐

  1. C#,码海拾贝(05)——拉格朗日(Lagrange)三点式曲线插值算法之C#源程序

    一.约瑟夫·拉格朗日 约瑟夫·拉格朗日(Joseph-Louis Lagrange,1736~1813)全名为约瑟夫·路易斯·拉格朗日,法国著名数学家.物理学家.1736年1月25日生于意大利都灵,1 ...

  2. C#,码海拾贝(11)——拉格朗日(Lagrange)三点式曲面插值(Surface Interpolation)算法C#源程序

    本文开始是曲面插值(Surface Interpolation,也称作:二维插值,二元插值). 数值计算三点式 数值计算三点式是一种常见的数值计算方法,它是通过对已知函数在某个点及其左右两个点处的函数 ...

  3. C#,码海拾贝(03)——积分(Integral Algorithm)算法类C#源程序

    一.引言 1.1 图书简介 <C#数值计算--算法编程>是2007年1月1日电子工业出版社出版的图书,由周长发编写. ISBN:9787121032035 本书囊括了近90个实用经典算法, ...

  4. [码海拾贝 之Perl]获取日期以及日期的加减

    前言 在Perl 中, 不安装其他模组的状况下, 可以使用 localtime 来获取当地日期和时间. 在标量上下文中, 返回的是字符串格式. my $localtime = localtime(); ...

  5. [码海拾贝 之TC] 使用View 定义动态的Class

    前言 在TC 中, Persistent Class 和 Table 是对应的关系. 定义一个Persistent的Class , updatedb 的时候就会产生对应的table. 在TC 的开发环 ...

  6. [码海拾贝 之TC] 呼叫外部应用程序或脚本

    前言 在Teamcenter Enterprise 的服务端开发中, 如何调用到外部的程序或是脚本. 一般, 呼叫外部的程序或脚本 在Java 中, 可以用这样的方式 Process child = ...

  7. [码海拾贝 之JS] JS 之删除数组中的元素

    前言 在Java 中要从一个list 中删除一个元素, 直接使用 remove 方法就可以了. 在js 中的array 并没有 remove 方法, 但是在js 中array 有splice 方法可以 ...

  8. [码海拾贝 之Perl]在字符串数组中查找特定的字符串是否存在

    前言 检索一个字符串是否存在于一个数组中, 最基本的想法应该就是对数组进行循环, 逐个判断数组的每个元素值和给定的值是否相等. (在Java语言还可以把数组转成 List , 在 list 中直接有 ...

  9. [码海拾贝 之JS] JS 之数组排序

    简单数组排序 这里的简单数组的定义是,数据的元素是基本的类型整型,字符型,浮点型等,而不是对象类型 排序方法就很简单,使用数组本身的sort 方法. 默认是升序排序. 看例子: <script& ...

最新文章

  1. python读取文件第n行-Python读取文件最后n行的方法
  2. 帝国cms调用相关文章若没有则调取最新文章
  3. 【数据结构与算法】之深入解析“石子游戏V”的求解思路与算法示例
  4. File类判断和获取功能
  5. vue数组修改不触发视图更新、vue向响应式对象添加或删除属性
  6. matlab 电力系统分析 毕设,基于MATLAB的P-Q分解法电力系统潮流计算毕业设计
  7. ApacheCN PythonWeb 译文集 20211110 更新
  8. python将object转换为float_如何在python中将datatype:object转换为float64?
  9. 《Java8实战》-第十章笔记(用Optional取代null)
  10. Java 高效编程之 Builder 模式
  11. poi操作ppt创建表格
  12. python 神奇时钟项目_第一个python小程序——即时动态时钟(代码解读)
  13. Protein Cell:扩增子和宏基因组数据分析实用指南
  14. 利用朴素贝叶斯算法解决“公园凉鞋问题”
  15. EUI库 - 自动布局
  16. 1.2、从“生日贺卡”看C++字符串的输入和输出
  17. UEFI 中的Gmac网卡驱动实现
  18. Swift 第三方库整理
  19. 安卓之软键盘监听与切换软键盘状态和重新获取EditText焦点
  20. 视频编码中的一些缩写

热门文章

  1. 信号功率及能量的理解
  2. lucene java maven_lucene Maven依赖
  3. 沈阳计算机考研学校排名,沈阳考研集训中心排名
  4. system verilog中的$sformatf()/$sformat()
  5. 校验、AJAX与过滤器
  6. 选型宝访谈:Office 365+微信=?
  7. VS2015命令行工具X86和X64版本
  8. python的ppt报告_python可以写PPT吗
  9. centos安装rpmforge
  10. C语言对自然对数的底数e精确计算