在三维空间曲线拟合点 [英] Curve fitting points in 3D space

查看:854
本文介绍了在三维空间曲线拟合点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图找到的功能,这将帮助我们通过一系列的点来绘制3D线。

Trying to find functions that will assist us to draw a 3D line through a series of points.

有关,我们知道每一个点:日期和放大器,时间,经纬度,高度,速度和航向。 数据可能会每10秒记录下来,我们希望能够guestimate点之间,增加粒度为1秒。因此,创建一个虚拟的飞行轨迹的三维空间。

For each point we know: Date&Time, Latitude, Longitude, Altitude, Speed and Heading. Data might be recorded every 10 seconds and we would like to be able to guestimate the points in between and increase granularity to 1 second. Thus creating a virtual flight path in 3D space.

我已经找到了一些曲线拟合算法,将通过一系列的点近似一条线,但他们并不能保证点相交。他们还没有考虑到速度和航向,以确定所采取的对象最有可能的路径到达下一个点。

I have found a number of curve fitting algorithms that will approximate a line through a series of points but they do not guarantee that the points are intersected. They also do not take into account speed and heading to determine the most likely path taken by the object to reach the next point.

推荐答案

从物理学的角度来看:

您必须承担你的中间点一些关于加速来获得插值。

You have to assume something about the acceleration in your intermediate points to get the interpolation.

如果你的物理系统比较乖巧(如汽车​​或飞机),而不是如反弹球,你可以继续假设你点之间的时间变化的线性加速。

If your physical system is relatively well-behaved (as a car or a plane), as opposed to for example a bouncing ball, you may go ahead supposing an acceleration varying linearly with time between your points.

对于恒定变化的加速运动矢量方程为:

The vector equation for a constant varying accelerated movement is:

 x''[t] = a t + b

在这里,除了•全部大小是矢量。

where all magnitudes except t are vectors.

对于每个段你已经知道V(T = T0)×(T = T0)tfinal和X(tfinal)V(tfinal)

For each segment you already know v(t=t0) x(t=t0) tfinal and x(tfinal) v(tfinal)

通过解你得到微分方程:

By solving the differential equation you get:

Eq 1:
x[t_] := (3 b t^2 Tf + a t^3 Tf - 3 b t Tf^2 - a t Tf^3 - 6 t X0 + 6 Tf X0 + 6 t Xf)/(6 Tf)  

和气势最初和最后的约束上的位置和速度,你得到:

And imposing the initial and final contraints for position and velocity you get:

公式2:

 a -> (6 (Tf^2 V0 - 2 T0 Tf Vf + Tf^2 Vf - 2 T0 X0 + 2 Tf X0 + 
        2 T0 Xf - 2 Tf Xf))/(Tf^2 (3 T0^2 - 4 T0 Tf + Tf^2))

 b -> (2 (-2 Tf^3 V0 + 3 T0^2 Tf Vf - Tf^3 Vf + 3 T0^2 X0 - 
        3 Tf^2 X0 - 3 T0^2 Xf + 3 Tf^2 Xf))/(Tf^2 (3 T0^2 - 4 T0 Tf + Tf^2))}}

所以插入值均衡器2到1当量你得到基于初始和最终位置和速度为您的积分时间内插,

So inserting the values for eqs 2 into eq 1 you get the temporal interpolation for your points, based on the initial and final position and velocities.

心连心!

修改

几个例子与突然的速度变化在两个​​维度上(在3D是完全一样的)。如果最初和最终速度都差不多,你会得到直的路径。

A few examples with abrupt velocity change in two dimensions (in 3D is exactly the same). If the initial and final speeds are similar, you'll get "straighter" paths.

假设:

X0 = {0, 0}; Xf = {1, 1};
T0 = 0;      Tf = 1;  

如果

V0 = {0, 1}; Vf = {-1, 3};

V0 = {0, 1}; Vf = {-1, 5};

V0 = {0, 1}; Vf = {1, 3};

下面是一个动画,你可能会看到从V0 = {0,1},以Vf的速度变化= {1,5}:

Here is an animation where you may see the speed changing from V0 = {0, 1} to Vf = {1, 5}:

在这里,你可以看到一个加速身体与3D等间隔所采取的立场:

Here you may see an accelerating body in 3D with positions taken at equal intervals:

修改

一个完整的问题:

为了方便起见,我将工作在直角坐标系。如果你想从纬度/日志/ ALT转换为笛卡尔只是做:

For convenience, I'll work in Cartesian coordinates. If you want to convert from lat/log/alt to Cartesian just do:

x = rho sin(theta) cos(phi)
y = rho sin(theta) sin(phi)
z = rho cos(theta)

其中Phi是经度,THETA是纬度,和Rho是你的高度加上地球的半径。

Where phi is the longitude, theta is the latitude, and rho is your altitude plus the radius of the Earth.

因此​​,假设我们开始段为:

So suppose we start our segment at:

 t=0 with coordinates (0,0,0) and velocity (1,0,0)

和结束的

 t=10 with coordinates (10,10,10) and velocity (0,0,1)  

我明确提出在坐标原点设置在我开始点原点的变化。这只是为了获得好的轮数...

I clearly made a change in the origin of coordinates to set the origin at my start point. That is just for getting nice round numbers ...

因此​​,我们在替换公式这些数字为a和b,并得到:

So we replace those numbers in the formulas for a and b and get:

a = {-(3/50), -(3/25), -(3/50)}  b = {1/5, 3/5, 2/5}  

有了这些,我们去公式1,对象的位置由下式给出:

With those we go to eq 1, and the position of the object is given by:

p[t] = {1/60 (60 t + 6 t^2 - (3 t^3)/5), 
        1/60 (18 t^2 - (6 t^3)/5), 
        1/60 (12 t^2 - (3 t^3)/5)}

这就是它。你从1至10秒以上公式中替换吨由其衣被合计的位置。
动画运行:

And that is it. You get the position from 1 to 10 secs replacing t by its valus in the equation above.
The animation runs:

编辑2

如果你不想惹的垂直加速度(也许是因为你的里程表不读它),你可以只以恒定的速度分配到Z轴(有一个很小的误差考虑它平行于轴线的Rho),等于(Zfinal - Zinit)/(TF-T0),然后解决问题在平面忘记高度

If you don't want to mess with the vertical acceleration (perhaps because your "speedometer" doesn't read it), you could just assign a constant speed to the z axis (there is a very minor error for considering it parallel to the Rho axis), equal to (Zfinal - Zinit)/(Tf-T0), and then solve the problem in the plane forgetting the altitude.

这篇关于在三维空间曲线拟合点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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