软件构造Lab1_Turtle Graphics

    1. Turtle Graphics

在这里简要概述你对该任务的理解。

      1. Problem 1: Clone and import

https://github.com/rainywang/Spring2020_HITCS_SC_Lab1/tree/master/P2

从此网址下载代码

创建git仓库

1.获取秘钥: ssh -keygen -t rsa -C “xxxxx”;

2.找到秘钥并复制添加到github上;

3.ssh –T git@github.com;

4.git config –global user.name ”xxxxx”;

5.git config –global user.emal ”xxxxx”;

      1. Problem 3: Turtle graphics and drawSquare

让画笔前进sideLength并转过90度四次。

      1. Problem 5: Drawing polygons

首先用多边形内角公式计算出内角角度

然后每次偏转180-内角

      1. Problem 6: Calculating Bearings

首先通过向量正切值得到弧度进而得到角度,由于初始角度为90度,所以偏转角为90-degree,若为负值则加360度得到正值。

然后多次调用calculateBearingToPoint计算每一组点的角度。

      1. Problem 7: Convex Hulls

点数小于等于3时,直接返回。大于3个点时,距离原点最远的点一定是凸包的某个顶点,所以先找到最右上角的点,而且转过最小的角度触碰到某个点,这个点就是凸包上的点,再加上上一次转过的角度为初始方向,这样重复下去,直到遇到第一个点为止,这样凸包就计算出来了。若转过的角度为0,点可能在边界上,就需要去掉中间的点。

      1. Problem 8: Personal art

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用Python的time模块来控制圆周运动的速度,修改代码如下: ```python import turtle import math import time # Set up the turtle screen screen = turtle.Screen() screen.bgcolor("white") screen.title("Circle with Moving Black Dot") # Create the turtle for drawing the circle circle_turtle = turtle.Turtle() circle_turtle.speed(0) circle_turtle.hideturtle() circle_turtle.penup() circle_turtle.goto(0, -80) circle_turtle.pendown() circle_turtle.color("black") circle_turtle.circle(80, 2880) # Create the turtle for drawing the black dot dot_turtle = turtle.Turtle() dot_turtle.speed(0) dot_turtle.hideturtle() dot_turtle.penup() dot_turtle.goto(40, 0) dot_turtle.pendown() dot_turtle.color("black") dot_turtle.begin_fill() dot_turtle.circle(4) dot_turtle.end_fill() # Calculate the angle increment for each frame of animation angle_increment = 200 / 60 # 200 degrees per second, 60 frames per second # Animate the movement of the black dot while True: dot_turtle.clear() angle = dot_turtle.heading() + angle_increment x = 80 * math.cos(math.radians(angle)) y = 80 * math.sin(math.radians(angle)) dot_turtle.goto(x, y) dot_turtle.begin_fill() dot_turtle.circle(6) # 小圆 dot_turtle.end_fill() time.sleep(1/60) # 控制运动速度 ``` 在上面的代码中,我们使用了time.sleep()函数来控制小圆的运动速度,将每帧的时间间隔设置为1/60秒。这样,小圆每秒绕大圆圈转200圈,同时每秒刷新60次界面,就可以实现流畅的圆周运动。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值