'************************************************************** '* Calculate angle of refraction for an incident ray using * '* Snell's Law * '* ---------------------------------------------------------- * '* SAMPLE RUN: * '* * '* Give indices for incident and refracting medium: 1, 1.5 * '* * '* What is the angle of incidence? 30 * '* * '* Refracted angle = 19.4712 * '* * '* ---------------------------------------------------------- * '* Ref.: "Problem Solving with Fortran 90 By David R. Brooks, * '* Springer-Verlag New York, 1997". * '* * '* Basic Release By J-P Moreau, Paris. * '* (www.jpmoreau.fr) * '************************************************************** ' Explanations: ' ------------ \ i! ' incident \ ! ' beam \! ' --------------------------- ' !* ' ! * refracted ' !r * beam ' ' ' Snell's Law: n sin(i) = n sin(r) ' i r ' -1 ' or r = sin [(n / n ) sin(i)] ' i r ' '-------------------------------------------------------------- 'Program Refract DEFDBL A-H, O-Z ' xni, xnr: double; (indices of refraction (dimensionless) ) ' xincident,refracted:double; (angles from perpendicular (deg) ) ' DegToRad: double; (required for trig functions ) ' sinus,cosinus: double; (auxiliary trig values ) pi = 3.1415926535# DegToRad = pi / 180# CLS PRINT INPUT " Give indices for incident and refracting medium: ", xni, xnr PRINT INPUT " What is the angle of incidence? ", xincident ' Convert refracted angle to degrees before displaying its value sinus = xni / xnr * SIN(xincident * DegToRad) cosinus = SQR(1# - sinus * sinus) refracted = ATN(sinus / cosinus) F\$ = "###.####" PRINT PRINT " Refracted angle = "; PRINT USING F\$; refracted / DegToRad END 'end of file refract.bas