from math
import pi, sin, cos, radians
from turtle
import Turtle
def main():
angle = eval(input('Enter the launch angle(in degrees):'))
vel = eval(input('Enter the initial velocity(in meters/sec):'))
h0 = eval(input('Enter the initial height(in meters):'))
time = eval(input('Enter the time interval:'))# 设置铅球的起始位置
xpos = 0
ypos = h0
theta = radians(angle)# 将输入的角度值转换为弧度值
xvel = vel * cos(theta)# 铅球的初始速度在x轴上的分量
yvel = vel * sin(theta)# 铅球的初始速度在y轴上的分量# 创建Turtle对象, 刚创建的小乌龟对象, 位于坐标原点( 0, 0), 朝向x轴正方向
t = Turtle()
t.color('red')# 设置画笔的颜色
t.pensize(2)# 线条粗细
t.speed(2)# 调整速度
t.hideturtle()# 隐藏小乌龟# 绘制x轴和y轴
t.forward(350)# 绘制x轴
t.goto(0, 0)# 回到坐标原点, 准备绘制y轴
t.goto(0, 200)# 绘制y轴
print('the position:({0:.3f},{1:0.3f})'.format(xpos, ypos))
xScale = 25# x坐标放大倍数
yScale = 30# y坐标放大倍数# 画笔移到铅球的起始位置, 准备绘制铅球的运行轨迹
t.goto(xpos * xScale, ypos * yScale)# 通过while循环绘制铅球的运行轨迹, 每隔time秒, 取一个点, 将所有取到的点连起来
while ypos >= 0:
xpos = xpos + time * xvel
yvel1 = yvel - time * 9.8
ypos = ypos + time * (yvel + yvel1) / 2.0
yvel = yvel1
print('the position:({0:.3f},{1:0.3f})'.format(xpos, ypos))
t.goto(xpos * xScale, ypos * yScale)
print('\nDistance traveled:{0:0.1f} meters.'.format(xpos))
if __name__ == '__main__':
main()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有