2016-09-21 177 views

回答

0
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分的东西,如:

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是点的X/Y轴45度和80个单位远离原点

1

click this pic for more clarity

在上面的图片。

坐标1,2,3,4,5,6,7,8-是上圆半径为R的圆周等距点和它的中心在X(0,0)

采取三角形XLZ,其正确地为L成角度,

让LZ = H, LY = A

XL + LY = R => XL + A = R => XL = R-A 

因为XLZ是直角,XZ平方= XL平方+ LZ平方

   R square = (R-A) square + h square ————1 

因为这8个点形成八角形θ= 360度/ 8 = 45度

tan 45度= h/XL = h/RA => -2

Z坐标(RA,H)=>(H,H)

从等式1和2

R平方= H平方+ H正方形=> 2小时平方= R square => h = R/sqrt 2

所以坐标点2(Z)= (R/SQRT2,R/SQRT2)

剩余可容易地推导出它们只是oppside

因此,所有的坐标

1(0,R) 2(R/SQRT2,R/(-R,sqrt2) 3(R,0) 4(-R/sqrt2,R/sqrt2) 5(-R,0) 6(-R/sqrt2,-R/sqrt2) 7(0,-R) (R/sqrt2,-R/sqrt2)