簡介
文中主要幫助一位小哥實現對圓的任意切分,切分需要從給定點,和給定角度進行切分。現把算法記錄如下,需要使用的可以參考,當然比較簡單。算法和效果如下。
代碼
import math
import matplotlib.pyplot as plt
import numpy as np
# def return_xy_list(alfa,):
# pass
r = 11.599
xa = -11.599
ya = 0.645941173792
x0 = 0
y0 = 0
alfa = 2
list_x=[]
list_y=[]
N=int(360/alfa)
for i in range(N):
theta=math.atan2(ya,xa)
theta2=math.atan2(ya,xa)+math.pi
print theta,theta2
x=x0+r*math.cos(theta-alfa*math.pi/180)
y = y0 + r * math.sin(theta - alfa*math.pi/180)
list_x.append(x)
list_y.append(y)
xa=x
ya=y
theta1 = np.arange(0, 2*np.pi, 0.01)
xx = x0 + r * np.cos(theta1)
yy = y0 + r * np.sin(theta1)
fig = plt.figure()
axes = fig.add_subplot(111)
axes.plot(xx, yy)
axes.axis('equal')
plt.title('test')
print list_x
print list_y
# print list_x[3]
# print list_y[3]
plt.plot(list_x,list_y)
axes.scatter(list_x, list_y, s=60, c='k', marker='x')
plt.show()
效果
切分30度
切分2度
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
