如何在曲线上均匀地重新分布点 [英] How to redistribute points evenly over a curve
问题描述
我有一些由 XYZ 笛卡尔点列表组成的 3 维任意曲线.这些点不是均匀分布的(有时间因素).如何使用应该构成曲线的给定点数重建"曲线.我看到这是在 3D 建模程序中完成的,所以我很确定这是可能的,我只是不知道如何.
I have some arbitrary curve in 3 dimensions made up of a list of XYZ cartesian points. The points are not evenly distributed (theres a time factor). How can I 'rebuild' the curve with a given number of points that should make up the curve. I see this done in 3D modeling programs so im pretty sure its possible, I just dont know how.
根据答案,我在 python 中需要它,所以我开始将 interparc 转换为 python.我得到了线性插值.它可能效率低下并且有冗余,但也许它对某人有用 http://pastebin.com/L9NFvJyA
Based on the answer, i needed it in python so i started working to convert interparc into python. I got as far as the linear interpolation. It is probably inefficient and has redundancies, but maybe it will be useful to someone http://pastebin.com/L9NFvJyA
推荐答案
我会使用 interparc,这是我设计的一个工具,正是为了做到这一点.它通过 2 维或更多维的一般空间曲线拟合样条,然后选择沿该曲线的距离等距的点.在三次样条的情况下,该解决方案使用 odesolver 来执行必须是数值积分的操作,因此速度稍慢,但仍然相当快.在许多情况下,一个简单的线性插值(正如我在这里使用的)就完全足够了,而且速度非常快.
I'd use interparc, a tool of mine designed to do exactly that. It fits a spline through a general space curve in 2 or more dimensions, then chooses points that are equally spaced in terms of distance along that curve. In the case of a cubic spline, the solution uses an odesolver to do what must be a numerical integration so it is a bit slower, but it is still reasonably fast. In many cases, a simple linear interpolation (as I used here) will be entirely adequate, and extremely fast.
该曲线可能是完全通用的,甚至与自身相交.我将给出一个 3 维空间曲线的简单示例:
The curve may be completely general, even crossing over itself. I'll give a simple example for a 3-d space curve:
t = linspace(0,1,500).^3;
x = sin(2*pi*t);
y = sin(pi*t);
z = cos(3*x + y);
plot3(x,y,z,'o')
grid on
box on
view(-9,12)
xyzi = interparc(100,x,y,z,'lin');
plot3(xyzi(:,1),xyzi(:,2),xyzi(:,3),'o')
box on
grid on
view(-9,12)
这篇关于如何在曲线上均匀地重新分布点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!