wordpress仿站教程网站建设配置文件无法粘贴

张小明 2026/1/2 11:00:11
wordpress仿站教程,网站建设配置文件无法粘贴,做网站要什么专业,哪些网站可以做免费外贸为了测试多边形之间的包含关系#xff0c;实现了用户设置圆半径和单位长度#xff0c;程序自动确定圆心位置。 import math import turtledef generate_polygon_circle(radius, unit_length):生成近似圆的多边形轮廓顶点坐标参数:radius: 半径unit_length:…为了测试多边形之间的包含关系实现了用户设置圆半径和单位长度程序自动确定圆心位置。importmathimportturtledefgenerate_polygon_circle(radius,unit_length): 生成近似圆的多边形轮廓顶点坐标 参数: radius: 半径 unit_length: 单位长度多边形的步长 返回: list: 多边形顶点坐标列表按顺时针顺序 ifradius0orunit_length0:return[]vertices[]# 圆心设为(r, r)以便所有坐标为正center_xradius center_yradius# 计算总步数每90度圆弧的步数steps_per_quadrantmax(1,int(radius/unit_length))# 存储第一象限的点不含起点first_quadrant_points[]# 计算第一象限的点从(0, r)开始顺时针到(r, 0)foriinrange(steps_per_quadrant1):xi*unit_lengthifxradius:# 防止x大于半径xradius y_sqmax(0,radius**2-x**2)ymath.sqrt(y_sq)first_quadrant_points.append((x,y))# 起点正上方 (r, 2r)start_xcenter_x start_ycenter_yradius vertices.append((start_x,start_y))# 第一象限右上1/4圆弧从顶部到右侧# 从第一个点接近顶部开始foriinrange(len(first_quadrant_points)-1,-1,-1):x_offset,y_offsetfirst_quadrant_points[i]xcenter_xx_offset ycenter_yy_offsetifvertices:last_x,last_yvertices[-1]# 插入直角顶点iflast_x!xandlast_y!y:vertices.append((last_x,y))vertices.append((x,y))# 第二象限右下1/4圆弧从右侧到底部foriinrange(len(first_quadrant_points)):x_offset,y_offsetfirst_quadrant_points[i]xcenter_xy_offset# 注意这里x和y交换因为是对称的ycenter_y-x_offset last_x,last_yvertices[-1]iflast_x!xandlast_y!y:vertices.append((last_x,y))vertices.append((x,y))# 第三象限左下1/4圆弧从底部到左侧foriinrange(len(first_quadrant_points)-1,-1,-1):x_offset,y_offsetfirst_quadrant_points[i]xcenter_x-x_offset ycenter_y-y_offset last_x,last_yvertices[-1]iflast_x!xandlast_y!y:vertices.append((last_x,y))vertices.append((x,y))# 第四象限左上1/4圆弧从左侧到顶部foriinrange(len(first_quadrant_points)):x_offset,y_offsetfirst_quadrant_points[i]xcenter_x-y_offset# 注意这里x和y交换因为是对称的ycenter_yx_offset last_x,last_yvertices[-1]iflast_x!xandlast_y!y:vertices.append((last_x,y))vertices.append((x,y))# 闭合多边形回到起点vertices.append(vertices[0])# 对坐标进行单位长度的整数倍调整adjusted_vertices[]forx,yinvertices:ifunit_length2:adj_xround(x/unit_length)*unit_length adj_yround(y/unit_length)*unit_lengthelse:adj_xround(x)adj_yround(y)adjusted_vertices.append((adj_x,adj_y))returnadjusted_verticesdefdraw_polygon_with_turtle(vertices,radius):使用turtle绘制多边形# 设置画布screenturtle.Screen()screen.title(近似圆的多边形)screen.setup(width800,height800)# 计算顶点坐标的范围all_x[xforx,_invertices]all_y[yfor_,yinvertices]min_x,max_xmin(all_x),max(all_x)min_y,max_ymin(all_y),max(all_y)# 计算缩放比例使图形占据画布的70%widthmax_x-min_x heightmax_y-min_y screen_width800screen_height800# 计算缩放比例scale_x(screen_width*0.7)/max(width,1)scale_y(screen_height*0.7)/max(height,1)scalemin(scale_x,scale_y)# 计算偏移量使图形居中offset_x(screen_width-width*scale)/2-min_x*scale offset_y(screen_height-height*scale)/2-min_y*scale# 创建画笔penturtle.Turtle()pen.speed(0)# 最快速度pen.width(2)# 移动到第一个点pen.penup()ifvertices:first_x,first_yvertices[0]scaled_xfirst_x*scaleoffset_x-screen_width/2scaled_yfirst_y*scaleoffset_y-screen_height/2pen.goto(scaled_x,scaled_y)# 绘制多边形pen.pendown()pen.color(blue)forx,yinvertices:scaled_xx*scaleoffset_x-screen_width/2scaled_yy*scaleoffset_y-screen_height/2pen.goto(scaled_x,scaled_y)# 绘制参考圆pen.penup()center_x(min_xmax_x)/2*scaleoffset_x-screen_width/2center_y(min_ymax_y)/2*scaleoffset_y-screen_height/2pen.goto(center_x,center_y-radius*scale)# 圆的底部pen.pendown()pen.color(red)pen.circle(radius*scale)# 标记顶点只标记部分顶点避免太密集pen.penup()pen.color(green)fori,(x,y)inenumerate(vertices):ifi%max(1,len(vertices)//20)0:# 只标记约20个点scaled_xx*scaleoffset_x-screen_width/2scaled_yy*scaleoffset_y-screen_height/2pen.goto(scaled_x,scaled_y-10)pen.write(f{i},aligncenter,font(Arial,8,normal))pen.hideturtle()screen.mainloop()# 测试函数deftest_circle_polygon():测试生成近似圆的多边形print(测试1: 半径10单位长度1)radius110unit11vertices1generate_polygon_circle(radius1,unit1)#draw_polygon_with_turtle(vertices1, radius1)print(顶点坐标:)fori,(x,y)inenumerate(vertices1):print(f{x:.0f},{y:.0f})print(f\n共{len(vertices1)}个顶点)print(\n*50)print(测试2: 半径10单位长度2)radius210unit22vertices2generate_polygon_circle(radius2,unit2)#draw_polygon_with_turtle(vertices2, radius2)print(顶点坐标:)fori,(x,y)inenumerate(vertices2):print(f{x:.0f},{y:.0f})print(f\n共{len(vertices2)}个顶点)print(\n*50)print(测试3: 半径21单位长度3)radius321unit33vertices3generate_polygon_circle(radius3,unit3)draw_polygon_with_turtle(vertices3,radius3)print(顶点坐标:)fori,(x,y)inenumerate(vertices3):print(f{x:.0f},{y:.0f})print(f\n共{len(vertices3)}个顶点)# 使用turtle绘制验证#draw_option input(\n是否使用turtle绘制验证图形(y/n): )#if draw_option.lower() y:# draw_polygon_with_turtle(vertices1, radius1)# 主程序if__name____main__:test_circle_polygon()
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

个人网站建设yxhuying常用网站开发语言

OpenProject 开源项目管理平台:敏捷团队协作的终极解决方案 【免费下载链接】taiga Taiga is a free and open-source project management for cross-functional agile teams. 项目地址: https://gitcode.com/gh_mirrors/taig/taiga 你是否曾经在项目管理中遇…

张小明 2026/1/1 10:59:55 网站建设

建设部注册监理工程师网站做区位分析的网站

还在为电脑运行缓慢、C盘空间告急而烦恼吗?每次打开电脑都要面对那个令人焦虑的红色警告提示,工作效率大打折扣。Windows Cleaner作为一款专业的系统优化工具,正是为你量身打造的救星! 【免费下载链接】WindowsCleaner Windows Cl…

张小明 2025/12/29 2:24:41 网站建设

wordpress写网站网站要背代码?

化学反应机理不仅揭示物质转化的内在规律,也为高效催化剂设计、绿色合成路径开发等工业应用提供关键依据。而要解析反应机理,离不开一项关键的计算技术——反应路径搜索,即通过在势能面(PES)上定位局部极小值与反应中间…

张小明 2025/12/29 2:24:06 网站建设

做微网站的第三方登录界面wordpress get_user_meta

中国行政区划矢量数据完全指南:从入门到实战 【免费下载链接】ChinaAdminDivisonSHP 项目地址: https://gitcode.com/gh_mirrors/ch/ChinaAdminDivisonSHP 想要获取准确的中国行政区划数据却不知从何入手?ChinaAdminDivisonSHP项目为你提供了完整…

张小明 2025/12/30 4:59:53 网站建设

网站设计费用多少wordpress ality 预览

从规模化的精酿啤酒厂,到创意十足的精酿啤酒工坊,再到热衷于自酿啤酒的爱好者家中,麦芽粉碎始终是酿造精酿啤酒的第一步。麦芽及大米、玉米、高粱等谷物原料,经粉碎后比表面积增大,能让麦粒内部物质更易溶解并均匀分散…

张小明 2025/12/29 2:22:55 网站建设