I dont know why cannot find widget or abbreviation for argument:'i1'. How to modify? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I dont know why cannot find widget or abbreviation for argument:'i1'. How to modify?

from ipywidgets import interact from pylab import * from math import * import matplotlib.pyplot as plt import numpy as py n1=0 n2=0 def Snell_law(n1,n2,i1): %matplotlib.inline axis[(-10,10,-10,10)] grid() axhline(color='c',linewidth=3) t=np.arange(0,10,0.1) if 90>=i1>asin(n2/n1)/pi*180: x=sin(i1/180*pi)*t y=cos(i1/180*pi)*t x1=sin(i1/180*pi)*-t y1=cos(i1/180*pi)*t elif 0<i1<=asin(n2/n1)/pi*180: x=sin(i1/180*pi)*t y=cos(i1/180*pi)*t x1=sin(i1/180*pi)*-t y1=sin(i1/180*pi)*t i2=asin(n1/n2*sin(x1))/pi*180 x2=sin(abs(n2)/180*pi)*-t y2=cos(abs(n2)/180*pi)*-t plt.plot(x,y,'-',label="rayon incident") plt.plot(x1,y1,'--',label="rayon refracte") plt.plot(x2,y2,'---',label="rayon reflechi") plt.legend() plt.title("Animation Snell_law") plt.show() interact(Snell_law, i1=(0,90,1) ,n1=(1,3,0.1) ,n2=(1,3,0.1))

24th Dec 2016, 8:58 PM
胡兆博
胡兆博 - avatar
2 Answers
+ 1
Before the if statement, try setting x, y, x1, y1, x2, and y2 to 0.
24th Dec 2016, 9:21 PM
DaemonThread
DaemonThread - avatar
+ 1
I don't think this is the answer to your question, but you forgot to add a colon at the end of the line on your first if statement on line 14.
24th Dec 2016, 9:42 PM
Harry H
Harry H - avatar