计算圆上8个等距点的像素坐标 [英] calculate pixel coordinates for 8 equidistant points on a circle

查看:85
本文介绍了计算圆上8个等距点的像素坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个以0为中心,半径为80的圆.如何使用python计算围绕圆的圆周的8个等距点的坐标?

I have a circle centred at 0 with radius 80. How using python do I calculate the coordinates for 8 equidistant points around the circumference of the circle?

推荐答案

r = 80
numPoints = 8.0
points = []
for index in range(numPoints):
    points.append([r*math.cos((index*2*math.pi)/numPoints),r*math.sin((index*2*math.pi)/numPoints)])
return points

如果您知道自己总是只有8分,可以简化一下:

you can simplify this some if you know you are always going to have only 8 points with something like:

r = 80
numPoints = 8
points = []
x = (r*math.sqrt(2))/2
points = [[0,r],[x,x],[r,0],[-x,x],[-r,0],[-x,-x],[0,-r],[x,-x]]
print points

x是点45度且距原点80单位的点的x/y

with x being the x/y of the point 45 degrees and 80 units away from the origin

这篇关于计算圆上8个等距点的像素坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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