栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

Python

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Python

Python_Turtle绘制正弦函数图像(采用函数描点法绘制)(turtle实现)
  • 1.SinDot.py
  • 2.结果示例

【注1】采用函数描点法绘制图像,最后一篇。要实现其他的函数图像使用turtle海龟库绘制,在代码中替换成相应的函数表达式即可。
【注2】采用点动成线的原理绘制,密集的描点即可!

1.SinDot.py
import turtle
import math
turtle.speed(0)
turtle.delay(0)
turtle.tracer(False)
i=-150
while(i<=150):
    i=i+0.1
    turtle.penup()
    y = 60*math.sin(0.06*i+0.5)+20
    turtle.goto(i,y)
    turtle.pendown()
    turtle.dot(4)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.seth(90)
turtle.fd(230)
turtle.seth(-70)
turtle.fd(15)
turtle.penup()
turtle.goto(0,230)
turtle.pendown()
turtle.seth(-110)
turtle.fd(15)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.seth(-90)
turtle.fd(90)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.seth(0)
turtle.fd(150)
turtle.seth(-160)
turtle.fd(15)
turtle.penup()
turtle.goto(150,0)
turtle.pendown()
turtle.seth(160)
turtle.fd(15)
turtle.penup()
turtle.goto(0,0)
turtle.pendown()
turtle.seth(-180)
turtle.fd(150)
turtle.penup()
turtle.goto(0,-120)
turtle.write("正弦函数方程图像:y = 60*math.sin(0.06*i+0.5)+20",True,align="center")
turtle.goto(0,-300)
turtle.done()
2.结果示例

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/498798.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号