一直想出一个字符串工具,一直没有去做
先把字符串的一个小功能记录,后续在不断添加吧
平分圆,且转换坐标
import math
radius = 9000
height = 28209.83
num_points = 72
for i in range(num_points):
angle = 2 * math.pi * i / num_points # 当前角度
x = radius * math.cos(angle) # x坐标
y = radius * math.sin(angle) # y坐标
z = height # z坐标
print(f"x={x:.2f}, y={y:.2f}, z={z:.2f}")
import re
data = '''
x=7372.37, y=-5162.19, z=28209.83
x=7794.23, y=-4500.00, z=28209.83
x=8156.77, y=-3803.56, z=28209.83
x=8457.23, y=-3078.18, z=28209.83
x=8693.33, y=-2329.37, z=28209.83
x=8863.27, y=-1562.83, z=28209.83
x=8965.75, y=-784.40, z=28209.83'''
x_list = []
y_list = []
z_list = []
for line in data.split('\n'):
x, y ,z = re.findall(r'[-+]?\d*\.\d+|\d+', line)[:3]
x_list.append(float(x))
y_list.append(float(y))
z_list.append(float(z))
print(x_list)
print(y_list)
print(z_list)