平均 3D 路径
我有两条 3D 路径,如果有的话,我想对它们进行“平均”。
我在采样时对 xyz 对进行了时间戳:
ms x y z
3 0.1 0.2 0.6
12 0.1 0.2 1.3
23 2.1 4.2 0.3
55 0.1 6.2 0.3
有关路径的事实:
- 它们都在同一 xyz 点/附近开始和结束。
- 我有完成路径所需的总持续时间以及各个顶点,
- 它们具有不同的长度(即不同数量的 xyz 对)。
任何帮助将不胜感激。
I have two paths in 3D and I want to "average" them, if there's such a thing.
I have the xyz pairs timestamped at the time they were sampled:
ms x y z
3 0.1 0.2 0.6
12 0.1 0.2 1.3
23 2.1 4.2 0.3
55 0.1 6.2 0.3
Facts about the paths:
- They all start and end on/near the same xyz point.
- I have the total duration it took to complete the path as well as individual vertices
- They have different lengths (i.e. different number of xyz pairs).
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
一个简单的方法如下...
首先构建一个函数
interp(t, T, waypoints)
,给定当前时间t
、总路径持续时间T
路径waypoints
返回当前位置。这可以使用线性插值或更复杂的方法来完成,以避免速度或加速度不连续。一旦你有了
interp
,平均路径可以定义为(Python 中的示例)平均路径的持续时间将是平均
T = (T1 + T2) / 2
两个持续时间。更改此方法以创建加权平均路径也很容易。
A simple method is the following...
First build a function
interp(t, T, waypoints)
that given the current timet
, the total path durationT
and the pathwaypoints
returns the current position. This can be done using linear interpolation or more sophisticated approaches to avoid speed or acceleration discontinuities.Once you have
interp
the average path can be defined as (example in python)the duration of the average path will be the average
T = (T1 + T2) / 2
of the two durations.It's also easy to change this approach to make a weighted average path.
在 R 中,该系列中连续点之间的距离(假设它位于名为“dat”的数据帧中)
可以是:
我可以想到几个平均值,即间隔内的平均距离、单位时间行驶的平均距离。取决于你想要什么。这给出了三个区间的平均速度:
In R, the distances between consecutive points in that series assuming it is in a dataframe named "dat"
would be:
There are a couple of averages I could think of average distance in interval, average distance traveled per unit time. Depends on what you want. This gives the average velocity in the three intervals:
肯定有这样的事情。对于路径 A 上的每个点,找到与路径 B 上的当前点对应的点,然后找到这些对应顶点之间的中点。然后,您将得到两条路径之间的一条路径,即两条路径的“平均值”。如果您没有对两条路径进行相同的采样而出现不匹配,则对于路径 A 上的内部点(即不是终点),找到路径上具有相似时间采样的两个最接近的采样点B,找到这三个点将形成的三角形的中点。
现在,由于您已经通过采样对路径进行了离散化,因此这个“平均值”只是一个近似值,而不是“真实”平均值,就像您可以通过求解
定义的两个可微参数函数之间的平均函数来实现的那样r(t) =
。There is definitely such a thing. For each point on path A, find the point that correponds to your current point on path B, and then find the mid-point between those corresponding verticies. You will then get a path in-between the two that is the "average" of the two paths. If you have a mis-match where you did not sample the two paths the same, then for an interior point on path A (i.e., not the end-point), find the two closest sampled points with a similar time-sampling on path B, and locate the mid-point of the triangle those three points will make.
Now since you've discreetized your path by sampling it, this "average" is only going to be an approximation, not a "true" average like you could do by solving for the average function between two differentiable parametric functions defined by
r(t) = <x(t), y(t), z(t)>
.扩展@6502的答案。
如果您希望检索构成平均路径的点列表,您可以在各个输入点的实例处对
avg
函数进行采样。 (向平均长度拉伸)Expanding on @6502's answer.
If you wish to retrieve a list of points that would make up the average path, you could sample the
avg
function at the instances of the individual input points. (Stretched toward the average length)