1 Star 0 Fork 2

chenyp401/CAM

forked from zzthfut/CAM 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
makeMessySeg.py 877 Bytes
一键复制 编辑 原始数据 按行查看 历史
zzthfut 提交于 2023-08-03 15:54 . 6-10
from GeomBase import Point3D
from Segment import Segment
import random
import math
def makeMessySegs(circleNum=10, segNumPerCircle=100000, radius=100):
segs = []
r = radius
for i in range(circleNum):
pnts = []
for j in range(segNumPerCircle):
theta = j / segNumPerCircle * 2 * math.pi
x = r * math.cos(theta)
y = r * math.sin(theta)
pnt = Point3D(x, y)
pnts.append(pnt)
pnts.append(pnts[0])
for j in range(len(pnts) - 1):
seg = Segment(pnts[j], pnts[j + 1])
segs.append(seg)
r += 10
length = len(segs)
print("segment count:", length)
print("min segment length:", segs[0].A.distance(segs[0].B))
for i in range(length):
rd = random.randint(0, length - 1)
segs[i], segs[rd] = segs[rd], segs[i]
return segs
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/chenyp401/cam.git
git@gitee.com:chenyp401/cam.git
chenyp401
cam
CAM
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385