如果我想生成一堆围绕圆圈均匀分布的点,我可以这样做(python):
If I want to generate a bunch of points distributed uniformly around a circle, I can do this (python):
r = 5 #radius n = 20 #points to generate circlePoints = [ (r * math.cos(theta), r * math.sin(theta)) for theta in (math.pi*2 * i/n for i in range(n)) ]但是,相同的逻辑不会在椭圆上产生均匀的点:端点上的点比边上的点间距更近。
However, the same logic doesn't generate uniform points on an ellipse: points on the "ends" are more closely spaced than points on the "sides".
r1 = 5 r2 = 10 n = 20 #points to generate ellipsePoints = [ (r1 * math.cos(theta), r2 * math.sin(theta)) for theta in (math.pi*2 * i/n for i in range(n)) ]是否有一种简单的方法可以在椭圆周围生成等距点?
Is there an easy way to generate equally spaced points around an ellipse?
推荐答案您必须计算周长,把它分成等长的弧。椭圆弧的长度是一个椭圆整数,不能写成闭合形式,所以你需要数值计算。
You have to calculate the perimeter, then divide it into equal length arcs. The length of an arc of an ellipse is an elliptic integral and cannot be written in closed form so you need numerical computation.
关于插件给wolfram提供了实现这个所需的公式,但这会很难看。
The article on ellipses on wolfram gives you the formula needed to do this, but this is going to be ugly.
更多推荐
我怎样才能生成一组沿椭圆周长均匀分布的点?
发布评论