资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

python绘制三角函数 python用三角函数

如何用python表示三角函数如题,能不能

Python编码下面的三角函数包括以下种类:

“只有客户发展了,才有我们的生存与发展!”这是创新互联公司的服务宗旨!把网站当作互联网产品,产品思维更注重全局思维、需求分析和迭代思维,在网站建设中就是为了建设一个不仅审美在线,而且实用性极高的网站。创新互联对网站设计、成都网站制作、网站制作、网站开发、网页设计、网站优化、网络推广、探索永无止境。

12345678910

acos(x) //返回x的反余弦弧度值。 asin(x) //返回x的反正弦弧度值。 atan(x) //返回x的反正切弧度值。 atan2(y, x) //返回给定的 X 及 Y 坐标值的反正切值。 cos(x) //返回x的弧度的余弦值。 hypot(x, y) //返回欧几里德范数 sqrt(x*x + y*y)。 sin(x) //返回的x弧度的正弦值。 tan(x) //返回x弧度的正切值。 degrees(x) //将弧度转换为角度,如degrees(math.pi/2) , 返回90.0 radians(x) //将角度转换为弧度

下面介绍了Python计算三角函数之asin()方法的使用(其它只需替换上述方法即可),返回x的反正弦,以弧度表示,代码如下:

12345678910111213

#!/usr/bin/python import math print "asin(0.64) : ", math.asin(0.64) print "asin(0) : ", math.asin(0) print "asin(-1) : ", math.asin(-1) print "asin(1) : ", math.asin(1) #运行结果如下:asin(0.64) : 0.694498265627asin(0) : 0.0asin(-1) : -1.57079632679asin(1) : 1.57079632679

如何用python完成:用自顶向下设计方法编写程序:在屏幕上打印三角函数y = sin(x)的图像。

I wrote this in Tkinter for you, in case you don't know Tkinter, it is a built-in module for most python versions.

If you want a commandline version, you can ask me, but tell you what, since those values are all

float numbers, so it's hard to get a precise graph in commandline window.

Well, in this version, I enlarged each element's position by 40 and then change them to integer, guess this is an endurable loss of precision.

#

from math import radians

from math import sin

from Tkinter import *

pos = []

xPos = 0

centerX = 0

centerY = 0

for deg in range(-360, 361, 10):

pos.append([xPos, int(40*(sin(radians(deg))))]) #1000 too big for my screen

xPos+=1

if deg == 0:

centerX = xPos-1

centerY = pos[-1][1]

root = Tk()

root.title('trianble graph from -180 to 180')

width, height = 550, 450

mHei = height/2

mWid = width/2

canvas = Canvas(root, width=width, height=height)

canvas.create_line(0, mHei, width, mHei)   #x axis

canvas.create_line(mWid, 0, mWid, height)  #y axis

xStep = (width-150)/len(pos)

yStep = (height-150)/len(pos)

radius = 3

# the middle point (sin(0) is first drawn and used as position reference for all

canvas.create_oval(mWid-radius, mHei-radius, mWid+radius, mHei+radius, fill='green')

print pos

print xStep, yStep, centerX, centerY

#exit(0)

for i in pos:

if i[0] == centerX: #center processed already.

continue

x = mWid + xStep*(i[0]-centerX)

# y is smaller, the bigger the value, so use minus

y = mHei - yStep*(i[1]-centerY)

canvas.create_oval(x-radius, y-radius, x+radius, y+radius, fill='green')

canvas.pack()

root.mainloop()

如何用python表示三角函数

在python中,有一个math module,你可以import math,里面有math.sin(), math.cos(), math.asin()和math.acos()四个函数。相信你也知道asin和acos的意思,就是arcsin和arccos。有了这四个函数你就可以求函数值和角度了。但是要注意括号里面填的数值,要用弧度制。

简单python语言编程:采用自顶向下设计方法编写程序:在屏幕上打印三角函数y = sin(x)的图像。

I just wrote an simple one for one other guy.

You may check it here and see if it's useful for you.

如何在python中表达三角函数,比如sin(x),tan(x),谢谢

在python中,有一个math

module,你可以import

math,

里面有math.sin(),math.cos(),math.asin()和math.acos()四个函数.

有了这四个函数你就可以求函数值和角度了.

注意:括号里面填的数值,要用弧度制.

sin15°用Python怎么表示?

Python的三角函数sin(),输入参数必须是弧度,所以要把角度变换为弧度

import math

# .... 输入度数到 degrees 变量....

# 例子里用 30度计算

degrees=30

radians = degrees * math.pi / 180.0

value = round( math.sin(radians), 4)

print(value)


网站栏目:python绘制三角函数 python用三角函数
链接分享:http://cdkjz.cn/article/dosoggi.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

业务热线:400-028-6601 / 大客户专线   成都:13518219792   座机:028-86922220