正剧开始:
星历2016年04月14日 10:26:31, 银河系厄尔斯星球中华帝国江南行省。
[工程师阿伟]正在和[机器小伟]一起研究[三角函数]。
把一个任意角度转化到这个[0, 360]范围内,小伟拿出了这样一个工具:
<span style="font-size:18px;">#把任意角转化成[0, 360]度范围内的角度。 #传入[度, 分,秒] #传出[度, 分,秒] def angleTransfer(a): #传入的角度可以只有度,也可也有分,也可以有秒 #这样会造成数组的大小变动 accuracy = len(a); if (a[0] < 0): if accuracy == 2: if (a[1] != 0): a[0]-=1; a[1] = 60-a[1]; elif accuracy == 3: if (a[1] != 0 or a[2] != 0): a[0] -=1; if (a[2] != 0): a[1] = 59-a[1]; a[2] = 60-a[2]; else: a[1] = 60-a[1]; while a[0] < 0: a[0]+=360; elif (a[0] >= 360): while a[0] >= 360: a[0]-=360; return a;</span>
<span style="font-size:18px;">>>> [129, 48, 0] [129, 59, 48] if __name__ == '__main__': print(angleTransfer([-950, 12, 0])); print(angleTransfer([-950, 0, 12]));</span>
小伟拿出了一件专门用来计算三角函数的法器:
<span style="font-size:18px;">### # @usage 三角函数调用封装 # @author mw # @date 2016年04月05日 星期二 09:36:50 # @param # @return # ### def triFun(task): #需要计算的任务 #输入量为角度制,依次为度,分,秒 #可输出显示度、分、秒的表达式 #用于计算锐角三角函数 #对于角度变换,还没有经过测试 #以后可扩展添加其它多种数学函数 size = len(task); result = []; import math; for i in range(size): taskNew = task[i]; part1 = angleTransfer(taskNew[1:]); len1 = len(part1); taskNew = [taskNew[0]]; for n in range(len1): taskNew.append(part1[n]); if task[i][0] == 'sin' or task[i][0] == 'cos' or task[i][0] == 'tan' \ or task[i][0] == 'cot': size_1 = len(task[i]); angle = 0; if size_1 == 2: angle = taskNew[1]; elif size_1 == 3: angle = taskNew[1]+taskNew[2]/60; elif size_1 == 4: angle = taskNew[1]+taskNew[2]/60+taskNew[3]/3600; angle = angle/180*math.pi; if task[i][0] == 'sin': s = ''; if size_1 == 2: s = task[i][0]+str(task[i][1])+'°'; elif size_1 == 3: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''; elif size_1 == 4: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″'; s += ' = '; s += str(round(math.sin(angle), 3)); s += '\n'; result.append(s); elif task[i][0] == 'cos': s = ''; if size_1 == 2: s = task[i][0]+str(task[i][1])+'°'; elif size_1 == 3: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''; elif size_1 == 4: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″'; s += ' = '; s += str(round(math.cos(angle), 3)); s += '\n'; result.append(s); elif task[i][0] == 'tan': s = ''; if size_1 == 2: s = task[i][0]+str(task[i][1])+'°'; elif size_1 == 3: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''; elif size_1 == 4: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″'; s += ' = '; s += str(round(math.tan(angle), 3)); s += '\n'; result.append(s); elif task[i][0] == 'cot': s = ''; if size_1 == 2: s = task[i][0]+str(task[i][1])+'°'; elif size_1 == 3: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''; elif size_1 == 4: s = task[i][0]+str(task[i][1])+'°'+str(task[i][2])+'\''+str(task[i][3])+'″'; s += ' = '; s += str(round(1/math.tan(angle), 3)); s += '\n'; result.append(s); else: if task[i][0] == 'asin': s = ''; s = task[i][0]+str(task[i][1])+' = '; res = math.asin(task[i][1])/math.pi*180; if res < 0: s += '-'; absres = abs(res); s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″'; s += '\n'; result.append(s); elif task[i][0] == 'acos': s = ''; s = task[i][0]+str(task[i][1])+' = '; res = math.acos(task[i][1])/math.pi*180; if res < 0: s += '-'; absres = abs(res); s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″'; s += '\n'; result.append(s); elif task[i][0] == 'atan': s = ''; s = task[i][0]+str(task[i][1])+' = '; res = math.atan(task[i][1])/math.pi*180; if res < 0: s += '-'; absres = abs(res); s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″'; s += '\n'; result.append(s); elif task[i][0] == 'acot': s = ''; s = task[i][0]+str(task[i][1])+' = '; res = 90-math.atan(task[i][1])/math.pi*180; if res < 0: s += '-'; absres = abs(res); s += str(math.floor(absres))+'°'+str(math.floor(absres*60)%60)+'\''+str(round(absres*3600)%60)+'″'; s += '\n'; result.append(s); else: pass; size = len(result); for i in range(size): print(result[i]); return result; #把任意角转化成[0, 360]度范围内的角度。 #传入[度, 分,秒] #传出[度, 分,秒] def angleTransfer(a): #传入的角度可以只有度,也可也有分,也可以有秒 #这样会造成数组的大小变动 accuracy = len(a); if (a[0] < 0): if accuracy == 2: if (a[1] != 0): a[0]-=1; a[1] = 60-a[1]; elif accuracy == 3: if (a[1] != 0 or a[2] != 0): a[0] -=1; if (a[2] != 0): a[1] = 59-a[1]; a[2] = 60-a[2]; else: a[1] = 60-a[1]; while a[0] < 0: a[0]+=360; elif (a[0] >= 360): while a[0] >= 360: a[0]-=360; return a; </span>
这件法器的作用在于如果需要计算包含度、分、秒的角度,它能给出比较好看的结果。
就像这样:
<span style="font-size:18px;">>>> sin172°25'12″ = 0.132 cos105°18'9″ = -0.264 sin-172°25'12″ = -0.132 cos-105°18'9″ = -0.264 tan-96° = 9.514 tan84° = 9.514 if __name__ == '__main__': task = [ ['sin', 172, 25, 12], ['cos', 105, 18, 9], ['sin', -172, 25, 12], ['cos', -105, 18, 9], ['tan', -96], ['tan', 84] ]; triFun(task);</span>
<span style="font-size:18px;">>>> sin300.0° = -0.866 cos300.0° = 0.5 tan300.0° = -1.732 if __name__ == '__main__': a = 5/3*180; task = [ ['sin', a], ['cos', a], ['tan', a] ]; triFun(task);</span>
<span style="font-size:18px;">>>> cos250° = -0.342 sin-45.0° = -0.707 tan-672° = 1.111 tan540° = -0.0 if __name__ == '__main__': task = [ ['cos', 250], ['sin', -180/4], ['tan', -672], ['tan', 3*180] ]; triFun(task);</span>
下面小伟想来画一画三角函数的图像:
坐标点可以这样得到:
<span style="font-size:18px;">def tmp(): import math; sin = []; cos = []; tan = []; for i in range(-360, 361, 10): sin.append([i, math.sin(i/180*math.pi)]); cos.append([i, math.cos(i/180*math.pi)]); tan.append([i, math.tan(i/180*math.pi)]); print(sin); print(cos); print(tan);</span>
这是正弦图:
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 0.25; var xS = -400, xE = 400; var yS = -1.5, yE = 1.5; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 2.4492935982947064e-16], [-350, 0.1736481776669304], [-340, 0.34202014332566943], [-330, 0.5000000000000004], [-320, 0.6427876096865396], [-310, 0.7660444431189781], [-300, 0.8660254037844386], [-290, 0.9396926207859083], [-280, 0.9848077530122081], [-270, 1.0], [-260, 0.984807753012208], [-250, 0.9396926207859082], [-240, 0.8660254037844384], [-230, 0.7660444431189779], [-220, 0.6427876096865393], [-210, 0.5000000000000001], [-200, 0.34202014332566866], [-190, 0.17364817766693047], [-180, -1.2246467991473532e-16], [-170, -0.1736481776669307], [-160, -0.3420201433256689], [-150, -0.49999999999999994], [-140, -0.6427876096865395], [-130, -0.766044443118978], [-120, -0.8660254037844387], [-110, -0.9396926207859084], [-100, -0.984807753012208], [-90, -1.0], [-80, -0.984807753012208], [-70, -0.9396926207859083], [-60, -0.8660254037844386], [-50, -0.766044443118978], [-40, -0.6427876096865393], [-30, -0.49999999999999994], [-20, -0.3420201433256687], [-10, -0.17364817766693033], [0, 0.0], [10, 0.17364817766693033], [20, 0.3420201433256687], [30, 0.49999999999999994], [40, 0.6427876096865393], [50, 0.766044443118978], [60, 0.8660254037844386], [70, 0.9396926207859083], [80, 0.984807753012208], [90, 1.0], [100, 0.984807753012208], [110, 0.9396926207859084], [120, 0.8660254037844387], [130, 0.766044443118978], [140, 0.6427876096865395], [150, 0.49999999999999994], [160, 0.3420201433256689], [170, 0.1736481776669307], [180, 1.2246467991473532e-16], [190, -0.17364817766693047], [200, -0.34202014332566866], [210, -0.5000000000000001], [220, -0.6427876096865393], [230, -0.7660444431189779], [240, -0.8660254037844384], [250, -0.9396926207859082], [260, -0.984807753012208], [270, -1.0], [280, -0.9848077530122081], [290, -0.9396926207859083], [300, -0.8660254037844386], [310, -0.7660444431189781], [320, -0.6427876096865396], [330, -0.5000000000000004], [340, -0.34202014332566943], [350, -0.1736481776669304], [360, -2.4492935982947064e-16]]; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); plot.setFillStyle('blue'); plot.fillText('y = sin(x)', -270, -170, 300); }</span>
这是余弦图:
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 0.25; var xS = -400, xE = 400; var yS = -1.5, yE = 1.5; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 1.0], [-350, 0.984807753012208], [-340, 0.9396926207859081], [-330, 0.8660254037844384], [-320, 0.7660444431189778], [-310, 0.6427876096865393], [-300, 0.5000000000000001], [-290, 0.342020143325669], [-280, 0.17364817766692997], [-270, -1.8369701987210297e-16], [-260, -0.17364817766693033], [-250, -0.3420201433256694], [-240, -0.5000000000000004], [-230, -0.6427876096865395], [-220, -0.766044443118978], [-210, -0.8660254037844386], [-200, -0.9396926207859084], [-190, -0.984807753012208], [-180, -1.0], [-170, -0.984807753012208], [-160, -0.9396926207859083], [-150, -0.8660254037844387], [-140, -0.7660444431189779], [-130, -0.6427876096865394], [-120, -0.4999999999999998], [-110, -0.3420201433256687], [-100, -0.1736481776669303], [-90, 6.123233995736766e-17], [-80, 0.17364817766693041], [-70, 0.3420201433256688], [-60, 0.5000000000000001], [-50, 0.6427876096865394], [-40, 0.766044443118978], [-30, 0.8660254037844387], [-20, 0.9396926207859084], [-10, 0.984807753012208], [0, 1.0], [10, 0.984807753012208], [20, 0.9396926207859084], [30, 0.8660254037844387], [40, 0.766044443118978], [50, 0.6427876096865394], [60, 0.5000000000000001], [70, 0.3420201433256688], [80, 0.17364817766693041], [90, 6.123233995736766e-17], [100, -0.1736481776669303], [110, -0.3420201433256687], [120, -0.4999999999999998], [130, -0.6427876096865394], [140, -0.7660444431189779], [150, -0.8660254037844387], [160, -0.9396926207859083], [170, -0.984807753012208], [180, -1.0], [190, -0.984807753012208], [200, -0.9396926207859084], [210, -0.8660254037844386], [220, -0.766044443118978], [230, -0.6427876096865395], [240, -0.5000000000000004], [250, -0.3420201433256694], [260, -0.17364817766693033], [270, -1.8369701987210297e-16], [280, 0.17364817766692997], [290, 0.342020143325669], [300, 0.5000000000000001], [310, 0.6427876096865393], [320, 0.7660444431189778], [330, 0.8660254037844384], [340, 0.9396926207859081], [350, 0.984807753012208], [360, 1.0]]; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); plot.setFillStyle('blue'); plot.fillText('y = cos(x)', -270, -170, 300); }</span>
这是正切图:
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 2; var xS = -400, xE = 400; var yS = -10, yE = 10; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 2.4492935982947064e-16], [-350, 0.176326980708465], [-340, 0.3639702342662032], [-330, 0.5773502691896265], [-320, 0.8390996311772806], [-310, 1.1917535925942102], [-300, 1.732050807568877], [-290, 2.74747741945462], [-280, 5.671281819617723], [-270, -5443746451065123.0], [-260, -5.67128181961771], [-250, -2.7474774194546168], [-240, -1.7320508075688754], [-230, -1.1917535925942093], [-220, -0.8390996311772799], [-210, -0.577350269189626], [-200, -0.3639702342662023], [-190, -0.1763269807084651], [-180, 1.2246467991473532e-16], [-170, 0.17632698070846534], [-160, 0.36397023426620256], [-150, 0.5773502691896257], [-140, 0.8390996311772804], [-130, 1.19175359259421], [-120, 1.7320508075688783], [-110, 2.7474774194546225], [-100, 5.671281819617711], [-90, -1.633123935319537e+16], [-80, -5.671281819617707], [-70, -2.7474774194546216], [-60, -1.7320508075688767], [-50, -1.19175359259421], [-40, -0.8390996311772799], [-30, -0.5773502691896257], [-20, -0.36397023426620234], [-10, -0.17632698070846498], [0, 0.0], [10, 0.17632698070846498], [20, 0.36397023426620234], [30, 0.5773502691896257], [40, 0.8390996311772799], [50, 1.19175359259421], [60, 1.7320508075688767], [70, 2.7474774194546216], [80, 5.671281819617707], [90, 1.633123935319537e+16], [100, -5.671281819617711], [110, -2.7474774194546225], [120, -1.7320508075688783], [130, -1.19175359259421], [140, -0.8390996311772804], [150, -0.5773502691896257], [160, -0.36397023426620256], [170, -0.17632698070846534], [180, -1.2246467991473532e-16], [190, 0.1763269807084651], [200, 0.3639702342662023], [210, 0.577350269189626], [220, 0.8390996311772799], [230, 1.1917535925942093], [240, 1.7320508075688754], [250, 2.7474774194546168], [260, 5.67128181961771], [270, 5443746451065123.0], [280, -5.671281819617723], [290, -2.74747741945462], [300, -1.732050807568877], [310, -1.1917535925942102], [320, -0.8390996311772806], [330, -0.5773502691896265], [340, -0.3639702342662032], [350, -0.176326980708465], [360, -2.4492935982947064e-16]]; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); plot.setFillStyle('blue'); plot.fillText('y = tan(x)', -270, -170, 300); }</span>
>>>
tan88° = 28.636
>>>
tan80° = 5.671
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 2; var xS = -400, xE = 400; var yS = -10, yE = 10; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 4082809838298842.5], [-350, 5.758770483143632], [-340, 2.9238044001630814], [-330, 1.9999999999999982], [-320, 1.5557238268604117], [-310, 1.3054072893322783], [-300, 1.1547005383792517], [-290, 1.0641777724759123], [-280, 1.015426611885745], [-270, 1.0], [-260, 1.0154266118857451], [-250, 1.0641777724759123], [-240, 1.154700538379252], [-230, 1.3054072893322788], [-220, 1.5557238268604126], [-210, 1.9999999999999996], [-200, 2.923804400163088], [-190, 5.758770483143629], [-180, -8165619676597685.0], [-170, -5.758770483143622], [-160, -2.923804400163086], [-150, -2.0000000000000004], [-140, -1.5557238268604119], [-130, -1.3054072893322786], [-120, -1.1547005383792515], [-110, -1.064177772475912], [-100, -1.0154266118857451], [-90, -1.0], [-80, -1.0154266118857451], [-70, -1.0641777724759123], [-60, -1.1547005383792517], [-50, -1.3054072893322786], [-40, -1.5557238268604126], [-30, -2.0000000000000004], [-20, -2.9238044001630876], [-10, -5.758770483143634], [10, 5.758770483143634], [20, 2.9238044001630876], [30, 2.0000000000000004], [40, 1.5557238268604126], [50, 1.3054072893322786], [60, 1.1547005383792517], [70, 1.0641777724759123], [80, 1.0154266118857451], [90, 1.0], [100, 1.0154266118857451], [110, 1.064177772475912], [120, 1.1547005383792515], [130, 1.3054072893322786], [140, 1.5557238268604119], [150, 2.0000000000000004], [160, 2.923804400163086], [170, 5.758770483143622], [180, 8165619676597685.0], [190, -5.758770483143629], [200, -2.923804400163088], [210, -1.9999999999999996], [220, -1.5557238268604126], [230, -1.3054072893322788], [240, -1.154700538379252], [250, -1.0641777724759123], [260, -1.0154266118857451], [270, -1.0], [280, -1.015426611885745], [290, -1.0641777724759123], [300, -1.1547005383792517], [310, -1.3054072893322783], [320, -1.5557238268604117], [330, -1.9999999999999982], [340, -2.9238044001630814], [350, -5.758770483143632], [360, -4082809838298842.5]]; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); plot.setFillStyle('blue'); plot.fillText('y = 1/sin(x)', -270, -170, 300); }</span>
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 2; var xS = -400, xE = 400; var yS = -10, yE = 10; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 1.0], [-350, 1.0154266118857451], [-340, 1.0641777724759125], [-330, 1.154700538379252], [-320, 1.305407289332279], [-310, 1.5557238268604126], [-300, 1.9999999999999996], [-290, 2.923804400163085], [-280, 5.758770483143646], [-270, -5443746451065123.0], [-260, -5.758770483143634], [-250, -2.923804400163082], [-240, -1.9999999999999982], [-230, -1.5557238268604119], [-220, -1.3054072893322786], [-210, -1.1547005383792517], [-200, -1.064177772475912], [-190, -1.0154266118857451], [-180, -1.0], [-170, -1.0154266118857451], [-160, -1.0641777724759123], [-150, -1.1547005383792515], [-140, -1.3054072893322788], [-130, -1.5557238268604123], [-120, -2.000000000000001], [-110, -2.9238044001630876], [-100, -5.758770483143635], [-90, 1.633123935319537e+16], [-80, 5.758770483143631], [-70, 2.9238044001630863], [-60, 1.9999999999999996], [-50, 1.5557238268604123], [-40, 1.3054072893322786], [-30, 1.1547005383792515], [-20, 1.064177772475912], [-10, 1.0154266118857451], [0, 1.0], [10, 1.0154266118857451], [20, 1.064177772475912], [30, 1.1547005383792515], [40, 1.3054072893322786], [50, 1.5557238268604123], [60, 1.9999999999999996], [70, 2.9238044001630863], [80, 5.758770483143631], [90, 1.633123935319537e+16], [100, -5.758770483143635], [110, -2.9238044001630876], [120, -2.000000000000001], [130, -1.5557238268604123], [140, -1.3054072893322788], [150, -1.1547005383792515], [160, -1.0641777724759123], [170, -1.0154266118857451], [180, -1.0], [190, -1.0154266118857451], [200, -1.064177772475912], [210, -1.1547005383792517], [220, -1.3054072893322786], [230, -1.5557238268604119], [240, -1.9999999999999982], [250, -2.923804400163082], [260, -5.758770483143634], [270, -5443746451065123.0], [280, 5.758770483143646], [290, 2.923804400163085], [300, 1.9999999999999996], [310, 1.5557238268604126], [320, 1.305407289332279], [330, 1.154700538379252], [340, 1.0641777724759125], [350, 1.0154266118857451], [360, 1.0]] ; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); plot.setFillStyle('blue'); plot.fillText('y = 1/cos(x)', -270, -170, 300); }</span>
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 2; var xS = -400, xE = 400; var yS = -10, yE = 10; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 4082809838298842.5], [-350, 5.671281819617708], [-340, 2.7474774194546163], [-330, 1.732050807568875], [-320, 1.191753592594209], [-310, 0.8390996311772798], [-300, 0.5773502691896258], [-290, 0.3639702342662027], [-280, 0.17632698070846456], [-270, -1.83697019872103e-16], [-260, -0.17632698070846495], [-250, -0.3639702342662031], [-240, -0.5773502691896264], [-230, -0.8390996311772805], [-220, -1.19175359259421], [-210, -1.7320508075688767], [-200, -2.747477419454623], [-190, -5.671281819617706], [-180, 8165619676597685.0], [-170, 5.671281819617698], [-160, 2.7474774194546208], [-150, 1.7320508075688774], [-140, 1.1917535925942095], [-130, 0.83909963117728], [-120, 0.5773502691896254], [-110, 0.36397023426620234], [-100, 0.17632698070846492], [-90, -6.123233995736766e-17], [-80, -0.17632698070846506], [-70, -0.36397023426620245], [-60, -0.577350269189626], [-50, -0.83909963117728], [-40, -1.19175359259421], [-30, -1.7320508075688774], [-20, -2.7474774194546225], [-10, -5.671281819617709], [10, 5.671281819617709], [20, 2.7474774194546225], [30, 1.7320508075688774], [40, 1.19175359259421], [50, 0.83909963117728], [60, 0.577350269189626], [70, 0.36397023426620245], [80, 0.17632698070846506], [90, 6.123233995736766e-17], [100, -0.17632698070846492], [110, -0.36397023426620234], [120, -0.5773502691896254], [130, -0.83909963117728], [140, -1.1917535925942095], [150, -1.7320508075688774], [160, -2.7474774194546208], [170, -5.671281819617698], [180, -8165619676597685.0], [190, 5.671281819617706], [200, 2.747477419454623], [210, 1.7320508075688767], [220, 1.19175359259421], [230, 0.8390996311772805], [240, 0.5773502691896264], [250, 0.3639702342662031], [260, 0.17632698070846495], [270, 1.83697019872103e-16], [280, -0.17632698070846456], [290, -0.3639702342662027], [300, -0.5773502691896258], [310, -0.8390996311772798], [320, -1.191753592594209], [330, -1.732050807568875], [340, -2.7474774194546163], [350, -5.671281819617708], [360, -4082809838298842.5]] ; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); plot.setFillStyle('blue'); plot.fillText('y = 1/tan(x)', -270, -170, 300); }</span>
<span style="font-size:18px;"> if (1) { var r = 20; config.setSector(1,1,1,1); config.graphPaper2D(0, 0, r); config.axis2D(0, 0,190); //坐标轴设定 var scaleX = 2*r, scaleY = 2*r; var spaceX = 50, spaceY = 0.5; var xS = -400, xE = 400; var yS = -2, yE = 2; config.axisSpacing(xS, xE, spaceX, scaleX, 'X'); config.axisSpacing(yS, yE, spaceY, scaleY, 'Y'); var array = [[-360, 0.9999999999999993], [-350, 0.6579798566743311], [-340, 0.3572123903134594], [-330, 0.13397459621556163], [-320, 0.015192246987791758], [-310, 0.01519224698779198], [-300, 0.13397459621556218], [-290, 0.3572123903134603], [-280, 0.6579798566743321], [-270, 1.0000000000000004], [-260, 1.3420201433256689], [-250, 1.6427876096865406], [-240, 1.8660254037844393], [-230, 1.9848077530122081], [-220, 1.9848077530122081], [-210, 1.8660254037844388], [-200, 1.6427876096865397], [-190, 1.342020143325668], [-180, 0.9999999999999997], [-170, 0.6579798566743313], [-160, 0.35721239031345964], [-150, 0.13397459621556085], [-140, 0.015192246987791869], [-130, 0.01519224698779198], [-120, 0.13397459621556118], [-110, 0.35721239031346086], [-100, 0.6579798566743311], [-90, 1.0000000000000002], [-80, 1.3420201433256693], [-70, 1.6427876096865397], [-60, 1.8660254037844386], [-50, 1.9848077530122081], [-40, 1.9848077530122081], [-30, 1.8660254037844384], [-20, 1.6427876096865393], [-10, 1.3420201433256687], [0, 0.9999999999999999], [10, 0.6579798566743311], [20, 0.3572123903134605], [30, 0.1339745962155613], [40, 0.01519224698779198], [50, 0.01519224698779198], [60, 0.1339745962155614], [70, 0.35721239031346075], [80, 0.6579798566743313], [90, 1.0], [100, 1.3420201433256687], [110, 1.6427876096865393], [120, 1.8660254037844386], [130, 1.9848077530122081], [140, 1.9848077530122081], [150, 1.8660254037844388], [160, 1.6427876096865395], [170, 1.3420201433256689], [180, 1.0000000000000002], [190, 0.6579798566743313], [200, 0.35721239031346075], [210, 0.13397459621556163], [220, 0.01519224698779198], [230, 0.015192246987791869], [240, 0.1339745962155614], [250, 0.3572123903134604], [260, 0.6579798566743306], [270, 0.9999999999999998], [280, 1.3420201433256689], [290, 1.6427876096865393], [300, 1.8660254037844388], [310, 1.9848077530122081], [320, 1.9848077530122081], [330, 1.8660254037844393], [340, 1.6427876096865404], [350, 1.3420201433256687], [360, 1.0000000000000004]] ; var size = array.length; var transform = new Transform(); var tmp = []; array = transform.scale(transform.translate(array, 0, 0), scaleX/spaceX, scaleY/spaceY); tmp = [].concat(array); shape.pointDraw(tmp, 'orange'); tmp = [].concat(array); shape.multiLineDraw(tmp, 'red'); plot.setFillStyle('blue'); plot.fillText('y = sin(2(x-pi/2)+1)', -270, -170, 300); }</span>
本节到此结束,欲知后事如何,请看下回分解。