离散均匀圆形分布(Discrete uniform circular distribution)

编程入门 行业动态 更新时间:2024-10-23 17:23:27
离散均匀圆形分布(Discrete uniform circular distribution) 在区间[0:360]中分配N个角度值的离散值 将这N个值映射到单位圆周上。 自动确定所有其他值之间的两个值。

有一般解决方案吗?

Have a distribution of a discrete number N of angular values in the interval [0:360] Map these N values onto a unit circumference. Automatically determine the two values between which all other values are.

Is there a general solution?

最满意答案

一种方法是计算平均角度,从你的所有角度减去这个,得到-circle / 2和circle / 2之间的结果(如果你使用弧度,例如圆是2pi)并取范围(意味着 - 角度+这些的最小值,平均角度+最大值)。

这可能至少在两个方面失败:你可能无法找到一个平均角度(北,东,南,西的平均值?),最小和最大可分别是-circle / 2和circle / 2,所以你的范围将是整个圈子。

我认为计算平均角度的“正确”方法是将所有角度转换为单位向量,取平均值并使用atan2求平均向量的方向; 这是平均角度。 但请注意,在n,e,s,w示例中,平均单位向量将为0,0而atan2将返回nan。

如果您使用的是C(ish)语言,则数学库函数余数对于标准化角度非常方便; 余数(a,圆)将在-circle / 2和circle / 2之间。

One way would be to compute the mean angle, subtract this from all your angles, getting a result between -circle/2 and circle/2 (where eg circle is 2pi if you are using radians) and take the range to be (mean-angle + the min of these, mean-angle + the max).

This could fail in at least two ways: you might fail to find a mean angle (whats the mean of north, east, south, west?) and the min and max could be -circle/2 and circle/2 respectively, so your range would be the whole circle.

I think the 'proper' way to compute the mean angle is to turn all the angles into unit vectors, take the average of these and use atan2 to find the orientation of the mean vector; this is the mean angle. But note that in the n,e,s,w example, the average unit vector would be 0,0 and atan2 would return nan.

If you're using a C (ish) language the math library function remainder is handy for normalising angles; remainder( a, circle) will be between -circle/2 and circle/2.

更多推荐

本文发布于:2023-08-07 01:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457907.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:圆形   均匀   Discrete   distribution   circular

发布评论

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

>www.elefans.com

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