A45091. Turtle.cirlce()函数半径,方向和弧度值的正负对结果的影响的测试
填空题
困难
知识点
题目描述
Turtle.cirlce()函数半径,方向和弧度值的正负对结果的影响的测试
参考答案
import turtle as t
"""
主要测试和circle函数的使用,了解不同方向时半径和弧度值的正负对结果的影响
不使用logo模式时:
"""
#下面这个对结果影响很大,不用时默认是"standard"# 朝右 (东)# 逆时针
# t.mode("logo") ## "logo" # 朝上 (北) # 顺时针
t.hideturtle() #隐藏海龟光标
t.dot(5) #绘制一个指定直径和颜色的圆点
t.fd(200) #向前200
t.home() #回到起始点 (角度也会恢复为初始状态的方向)
# t.fd(-200)
# t.home()
t.seth(180) # 转到+180度 (绝对角度)向左
t.fd(200)
t.home()
t.seth(-90) # 转到-90度 (绝对角度)向下
t.fd(200)
t.home()
t.seth(90) # 转到+90度 (绝对角度)向上
t.fd(200)
t.home()
# 测试trutle.circle()函数
#circle函数参数:半径和弧度 ,
# 半径为正(负),表示圆心在画笔的左边(右边)画圆
# t.color("black") #默认就是黑色
t.pensize(15)
# 初始方向是向右-->
t.circle(100, 90) #半径和弧度 , 逆时针(第一象限) 圆心在上方
t.home()
t.circle(100, -90) #半径和弧度 ,顺时针,反方向画(第四象限)圆心在上方
t.home()
t.circle(-100, 90) #半径和弧度 , 顺时针(第二象限) 圆心在下方
t.home()
t.circle(-100, -90) #半径和弧度 ,逆时针,反方向画(第三象限)圆心在下方
t.home()
# 对比方向值
t.seth(-180) #向左
t.seth(0) #向右
t.seth(90) #向上
t.seth(-90) #向下
t.seth(180) #也向左
t.color("pink")
t.pensize(12)
# 方向向左<--
t.circle(100, 90) #半径和弧度 ,第三象限 圆心在下方 此时等价于<==> 方向为右时的(-100,-90),值乘以-1,
t.home()
t.seth(-180)
t.circle(100, -90) #半径和弧度 ,第二象限 圆心在下方 此时等价于<==> 方向为右时的(-100, 90)
t.home()
t.seth(180)
t.circle(-100, -90) #半径和弧度 ,第一象限 圆心在上方 此时等价于<==> 方向为右时的(100,90),值乘以-1,
t.home()
t.seth(180)
t.circle(-100, 90) #半径和弧度 ,第四象限 圆心在上方 此时等价于<==> 方向为右时的(100, -90)
t.home()
#总结:方向向左和向右边时,半径为正(负),表示圆心在画笔的上边(下边)画圆
t.color("blue")
t.pensize(9)
####测试方向为上下时的情况
t.seth(90)
# 方向向上↑
t.circle(100, 90) #半径和弧度 ,第四象限 圆心在左方
t.home()
t.seth(90)
t.circle(100, -90) #半径和弧度 ,第三象限 圆心在左方
t.home()
t.seth(90)
t.circle(-100, -90) #半径和弧度 ,第二象限 圆心在右方
t.home()
t.seth(90)
t.circle(-100, 90) #半径和弧度 ,第一象限 圆心在右方
t.home()
####
t.color("green")
t.pensize(6)
t.seth(-90)
# 方向向下↓
t.circle(100, 90) #半径和弧度 ,第二象限 圆心在右方
t.home()
t.seth(-90)
t.circle(100, -90) #半径和弧度 ,第一象限 圆心在右方
t.home()
t.seth(-90)
t.circle(-100, -90) #半径和弧度 ,第四象限 圆心在左方
t.home()
t.seth(-90)
t.circle(-100, 90) #半径和弧度 ,第三象限 圆心在左方
t.home()
#############
t.pencolor("red")
t.pensize(2)
t.seth(-180) #绝对角度(向左),所以没有改变
t.lt(180) #左转180 ,当前方向的转向 left的简写; right 简写rt
###圆心在上下两边的两个圆 ,方向可以选择左或右
# t.seth(0) #绝对角度(向右)
t.circle(102, 180) #半径和弧度 ,
t.pu()
t.home()
# t.seth(0) #绝对角度(向右)
t.pd()
t.circle(102, -180) #半径和弧度 ,
t.pu()
t.home()
# t.seth(0) #绝对角度(向右)
t.pd()
t.circle(-102, 180) #半径和弧度 ,
t.pu()
t.home()
# t.seth(0) #绝对角度(向右)
t.pd()
t.circle(-102, -180) #半径和弧度 ,
t.pu()
t.home()
########## 补充圆心在左右两边的两个圆,方向可以选择上或下
t.pencolor("yellow")
t.seth(90) #绝对角度(向上)
t.pd()
t.circle(102, 180) #半径和弧度 ,
t.pu()
t.home()
t.seth(90) #绝对角度(向上)
t.pd()
t.circle(102, -180) #半径和弧度 ,
t.pu()
t.home()
t.seth(90) #绝对角度(向上)
t.pd()
t.circle(-102, 180) #半径和弧度 ,
t.pu()
t.home()
t.seth(90) #绝对角度(向上)
t.pd()
t.circle(-102, -180) #半径和弧度 ,
t.pu()
t.home()
t.done()
上一题
下一题