如何在曲线上均匀地重新分配点 [英] How to redistribute points evenly over a curve

查看:128
本文介绍了如何在曲线上均匀地重新分配点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个维度的任意曲线,这些曲线由XYZ笛卡尔点列表组成.这些点分布不均匀(以时间为单位).如何使用给定数量的点组成曲线来重建"曲线.我看到这是在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 ,这是我专门设计的工具.它可将样条曲线拟合为二维或更大尺寸的一般空间曲线,然后选择沿该曲线的距离相等的点.在三次样条曲线的情况下,该解决方案使用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屋!

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