3D空间中的曲线拟合点

编程入门 行业动态 更新时间:2024-10-16 02:22:28
本文介绍了3D空间中的曲线拟合点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

试图找到有助于我们通过一系列点绘制 3D 线的函数.

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

对于我们知道的每个点:日期和时间、纬度、经度、高度、速度和航向.数据可能每 10 秒记录一次,我们希望能够推测出两者之间的点并将粒度增加到 1 秒.从而在 3D 空间中创建虚拟飞行路径.

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

其中除 t 之外的所有幅度都是向量.

where all magnitudes except t are vectors.

对于每个段,您已经知道 v(t=t0) x(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))}}

因此,将 eqs 2 的值插入到 eq 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:

编辑

一个完整的问题:

为方便起见,我将使用笛卡尔坐标.如果您想从 lat/log/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}  

对于那些我们去 eq 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)}

就是这样.用上面等式中的值替换 t,您可以获得 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.

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

更多推荐

[db:关键词]

本文发布于:2023-04-14 05:29:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/836707.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:曲线   空间

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!