我怎样才能生成一组沿椭圆周长均匀分布的点? [英] How can I generate a set of points evenly distributed along the perimeter of an ellipse?

查看:597
本文介绍了我怎样才能生成一组沿椭圆周长均匀分布的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我想生成一堆围绕圆圈均匀分布的点,我可以这样做(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.

这篇关于我怎样才能生成一组沿椭圆周长均匀分布的点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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