[tmp]202610081644

This commit is contained in:
starcells committed 2026-10-08 16:44:53 +08:00
1 parent bc625a9e7b
commit f3fa7d1b34
1 file changed
+32 -4
+32 -4
View File
@@ -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) )