From f3fa7d1b3431b21dba3dd97560b4fb771910f767 Mon Sep 17 00:00:00 2001 From: StarCells Date: Thu, 8 Oct 2026 16:44:53 +0800 Subject: [PATCH] [tmp]202610081644 --- spectro.py | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/spectro.py b/spectro.py index 2747015..6447517 100644 --- a/spectro.py +++ b/spectro.py @@ -6,10 +6,25 @@ class LightDir: beta = -1 gamma = -1 + def __init__(self,a,b,g): + self.alpha = a + self.beta = b + self.gamma = g + + def another_abs(dir1,dir2): + tmp = 1-math.cos(dir1)**2-math.cos(dir2)**2 + if(tmp > 1 or tmp < 0): + return None + return math.acos(math.sqrt(tmp)) + class LightWaveVec: wavenum = 0.0 - direction = LightDir() + direction = LightDir(-1,-1,-1) + + def __init__(self,wave_num,wave_dir): + self.wavenum = wave_num + self.direction = wave_dir def diffracted_light(incident_light, diffraction_order, grating_constant): ans = [] @@ -28,10 +43,10 @@ class LightWaveVec: # TODO: EXPLAIN THEIR PHYSICAL MEANING ans.append(LightWaveVec(dif_wavenum, LightDir( # cos(alpha) **2 + cos(beta) **2 + cos(gamma) **2 = 1 - # For it's a reflective grating, take the opposite - - math.acos(math.sqrt(tmp_alpha)), + # For it's a reflective grating, take the opposite num of gamma + math.acos(math.sqrt(tmp_alpha)), dif_beta, - dif_gamma + -dif_gamma ))) # wavelen = 1/wavenum @@ -47,3 +62,16 @@ class LightWaveVec: try_diffract(tmp_gamma_2) return ans + +beta_i = 51.9086765665 / 180 * math.pi +gamma_i = 104.1539440993 / 180 * math.pi +alpha_i = LightDir.another_abs(beta_i,gamma_i) +light_i = LightWaveVec(1/(370*10^-9),LightDir(alpha_i,beta_i,gamma_i)) +k = 1 +d = 1400*10^-9 +light_r = LightWaveVec.diffracted_light(light_i,k,d) + +for l in light_r: + print("alpha_x:",math.cos(l.direction.alpha) ) + print("beta_y:",math.cos(l.direction.beta) ) + print("gamma_z:",math.cos(l.direction.gamma) ) \ No newline at end of file