在一定距离后得到catmull rom样条的点? [英] Getting the point of a catmull rom spline after a certain distance?

查看:170
本文介绍了在一定距离后得到catmull rom样条的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一定长度的 Catmull-Rom样条曲线,计算其在一定距离的位置?通常,在catmull rom样条中计算点,您输入0和1之间的值以通过比例获得其位置,我如何对距离进行此操作?例如,如果我的样条是30单位长,我怎么能得到它的位置在距离8?

If I have a Catmull-Rom spline of a certain length how can I calculate its position at a certain distance? Typically to calculate the point in a catmull rom spline you input a value between 0 and 1 to get its position via proportions, how can I do this for distances? For example if my spline is 30 units long how can I get its position at distance 8?

我问的原因是因为它似乎与catmull rom splines给点[0,1]域不保证它会给你在那个距离的点到样条,例如如果我输入0.5到一个长度30的catmull romspline它不意味着我会得到在距离的位置15,除非样条本身实际上是一条直线。

The reason I ask is because it seems with catmull rom splines giving points in the [0,1] domain does not guarantee that it will give you the point at that distance into the spline, for example if I input 0.5 into a catmull romspline of length 30 it does not mean I'll get the position at the distance of 15 of the spline unless the spline itself is in effect a straight line..

推荐答案

通常的方法是存储每个段,然后找出一个段的部分长度,您将t增加一个epsilon值,并计算2点之间的直线距离,直到你打你的答案。显然你的epsilon越小,你得到的结果越好,但它给出令人惊讶的好结果。我使用这种方法沿恒定速度沿着catmul-rom移动,你不能看到它加速和减速...它以恒定速度移动。显然,根据你的分段的紧张程度,你的epsilon值将需要改变,但一般来说,你可以选择一个足够好的epsilon,一切都会很好。

The usual way is to store length of each segment and then to find out the partial length of a segment you increment t by an epsilon value and calculate the linear distance between the 2 points until you hit your answer. Obviously the smaller your epsilon the better the result you get but it gives surprisingly good results. I used this method for moving at a constant speed along a catmul-rom and you cannot see it speed up and slow down ... it DOES move at a constant speed. Obviously depending on how tight your segments are your epsilon value will need to change but, in general, you can pick a "good enough" epsilon and everything will be fine.

Findinf的答案非迭代是令人难以置信的昂贵(我已经看到了派生一个回来,它不漂亮;))。您将必须有一个小的ε值以获得更差的性能...

Findinf the answer non-iteratively is INCREDIBLY expensive (I have seen the derivation a while back and it was not pretty ;)). You will have to have a tiny epsilon value to get worse performance ...

这篇关于在一定距离后得到catmull rom样条的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆