博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
niku 5.8
阅读量:7031 次
发布时间:2019-06-28

本文共 1484 字,大约阅读时间需要 4 分钟。

 

得到的图theta2和答案不一样,不知道为什么,需要再检查!!!!!

"""niku 习题5.8"""""" 乘除法要用数组  将列表转换为数组"""import numpy as npimport matplotlib.pyplot as pltimport math  plt.figure(figsize=(8,4))""" 求theta1""" t =  np.arange(1,12,1)#生成一个数组,不是列表px = list(np.array([3]*11))py = list(np.arange(5,-6,-1))pz = list(np.array([5]*11))theta1=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]theta2=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]theta3=[0.,0.,0.,0.,0.,0.,0.,0.,0.,0.,0.]for s in range(0,11):    a =math.atan2(px[s],py[s])    theta1[s] = a#print(theta1)   """求theta3""" for s in range(0,11):    f = math.acos(((py[s]/math.cos(theta1[s]))**2+(pz[s]-8)**2-162)/162 )        theta3[s] = f#print(theta3)    """求theta2"""for s in range(0,11):    q = math.cos(theta1[s])*(pz[s]-8)*(1+math.cos(theta3[s]))+py[s]*math.sin(theta3[s])    e = 18*(1+math.cos(theta3[s]))*math.cos(theta1[s])    t = math.acos(q/e)    theta2[s] = t*180/3.1415    for s in range(0,11):    t = theta1[s]    theta1[s] = t*180/3.1415for s in range(0,11):    t = theta3[s]    theta3[s] = t*180/3.1415"""开始画图 画图的时候要用数组"""t = np.arange(1,12,1)theta1 = np.array(theta1)theta2 = np.array(theta2)theta3 = np.array(theta3)plt.plot(t,theta1,label="$theta1$",color="red",linewidth=2)plt.plot(t,theta2,label="$theta2$",color="blue",linewidth=2)plt.plot(t,theta3,label="$theta3$",color="green",linewidth=2)plt.ylim(-20,180)plt.xlim(-1,12)plt.xlabel("point")plt.ylabel("theta")plt.legend(loc="upper left")plt.grid(True)plt.show()

  

 

转载于:https://www.cnblogs.com/hundanlin/p/8491666.html

你可能感兴趣的文章
小鸡吃米
查看>>
FFmpeg AVFMT_NOFILE宏定义剖析
查看>>
Windows Server 2008 R2活动目录回收站
查看>>
能吃遍全世界的方便面,你也是人生赢家
查看>>
为什么使用LR11录制完,发现脚本每个页面都被录制了两遍?
查看>>
Fedora 删除旧内核
查看>>
浏览器静态资源的版本控制新思路.强制更新指定资源缓存.的探讨
查看>>
NSCalendar
查看>>
Ios 入门 ----WebView 控件
查看>>
scala编译错误
查看>>
VMware Horizon 6 介绍
查看>>
ansible的使用
查看>>
2012年2月10日
查看>>
Linux下Web服务器应用之网站安全-https
查看>>
关于循环嵌套循环
查看>>
Scala中常见的容器 Option(选项)
查看>>
算法-蛇型矩阵
查看>>
路由交换IOS的备份与还原
查看>>
05.swift ?可选类型
查看>>
JavaSE 学习参考:方法的参数
查看>>