2016-09-21 151 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)

相關問題