How does the centripetal Catmull–Rom spline work?(向心 Catmull-Rom 样条如何工作?)
问题描述
来自这个网站,里面似乎有关于Catmull的最详细的信息-Rom 样条,似乎需要四个点来创建样条.但是,它没有提到点 p0 和 p3 如何影响 p1 和 p2 之间的值.
From this site, which seems to have the most detailed information about Catmull-Rom splines, it seems that four points are needed to create the spline. However, it does not mention how the points p0 and p3 affect the values between p1 and p2.
我的另一个问题是如何创建连续样条曲线?通过使 p4 = p2(即,假设我们有 p0, p1, p2, p3, p4, p5, p6, ..., pN).
Another question I have is how would you create continuous splines? Would it be as easy as defining the points p1, p2 to be continuous with p4, p5 by making p4 = p2 (that is, assuming we have p0, p1, p2, p3, p4, p5, p6, ..., pN).
一个更普遍的问题是如何计算 Catmull-Rom 样条上的切线?考虑到这些输入值给出的位置坐标,它是否必须涉及在样条上取两个点(比如在 0.01、0.011)并根据毕达哥拉斯得到切线?
A more general question is how would one calculate tangents on Catmull-Rom splines? Would it have to involve taking two points on the spline (say at 0.01, 0.011) and getting the tangent based on Pythagoras, given the position coordinates those input values give?
推荐答案
看看等式 2 - 它描述了控制点如何影响线.您可以看到点P0 和
P3
进入了沿着从P1
到P2
的曲线绘制点的方程.您还将看到,当 t == 0
和 P2
当 t == 1
时,等式给出了 P1
.
Take a look at equation 2 -- it describes how the control points affect the line. You can see points P0
and P3
go into the equation for plotting points along the curve from P1
to P2
. You'll also see that the equation gives P1
when t == 0
and P2
when t == 1
.
这个示例方程可以推广.如果您有点 R0
, R1
, ... RN
那么您可以绘制 RK
和 之间的点RK + 1
使用等式 2 和 P0 = RK - 1
, P1 = RK
, P2 = RK + 1
和 <代码>P3 = RK + 2.
This example equation can be generalized. If you have points R0
, R1
, … RN
then you can plot the points between RK
and RK + 1
by using equation 2 with P0 = RK - 1
, P1 = RK
, P2 = RK + 1
and P3 = RK + 2
.
你不能从 R0
到 R1
或从 RN - 1
到 RN
绘图,除非你添加R - 1
和 RN + 1
的额外控制点.总体思路是,您可以选择要添加到序列的头部和尾部的任何点,为自己提供计算样条的所有参数.
You can't plot from R0
to R1
or from RN - 1
to RN
unless you add extra control points to stand in for R - 1
and RN + 1
. The general idea is that you can pick whatever points you want to add to the head and tail of a sequence to give yourself all the parameters to calculate the spline.
您可以通过删除它们之间的控制点之一来将两条样条线连接在一起.假设您有 R0
、R1
、...、RN
和 S0
、S1
,... SM
它们可以连接成 R0
, R1
, ..., RN - 1
, S1
, S2
, ... SM
.
You can join two splines together by dropping one of the control points between them. Say you have R0
, R1
, …, RN
and S0
, S1
, … SM
they can be joined into R0
, R1
, …, RN - 1
, S1
, S2
, … SM
.
要计算任意点的切线,只需对等式 2 求导即可.
To compute the tangent at any point just take the derivative of equation 2.
这篇关于向心 Catmull-Rom 样条如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:向心 Catmull-Rom 样条如何工作?
基础教程推荐
- 使用从字符串中提取的参数调用函数 2022-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07