我怎样才能生成一组沿椭圆周长均匀分布的点?

编程入门 行业动态 更新时间:2024-10-06 17:12:55
本文介绍了我怎样才能生成一组沿椭圆周长均匀分布的点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

更多推荐

我怎样才能生成一组沿椭圆周长均匀分布的点?

本文发布于:2023-11-30 18:33:46,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:周长   椭圆   均匀

发布评论

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

>www.elefans.com

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