#ifndef RTS_HALFSPACE_H #define RTS_HALFSPACE_H namespace rts{ template class halfspace; template class efield; } template void operator<<(rts::efield &ef, rts::halfspace hs); namespace rts{ template class halfspace { private: rts::plane S; //surface plane splitting the half space rts::complex n0; //refractive index at the front of the plane rts::complex n1; //refractive index at the back of the plane //lists of waves in front (pw0) and behind (pw1) the plane std::vector< rts::planewave > w0; std::vector< rts::planewave > w1; //rts::planewave pi; //incident plane wave //rts::planewave pr; //plane wave reflected from the surface //rts::planewave pt; //plane wave transmitted through the surface void init(){ n0 = 1.0; n1 = 1.5; } //compute which side of the interface is hit by the incoming plane wave (0 = front, 1 = back) bool facing(planewave p){ if(p.kvec().dot(S.norm()) > 0) return 1; else return 0; } T calc_theta_i(vec v){ vec v_hat = v.norm(); //compute the cosine of the angle between k_hat and the plane normal T cos_theta_i = v_hat.dot(S.norm()); return acos(abs(cos_theta_i)); } T calc_theta_t(T ni_nt, T theta_i){ T sin_theta_t = ni_nt * sin(theta_i); return asin(sin_theta_t); } public: //constructors halfspace(){ init(); } halfspace(T na, T nb){ init(); n0 = na; n1 = nb; } halfspace(T na, T nb, plane p){ n0 = na; n1 = nb; S = p; } //compute the transmitted and reflective waves given the incident (vacuum) plane wave p void incident(rts::planewave p){ planewave r, t; p.scatter(S, n1.real()/n0.real(), r, t); //std::cout<<"i+r: "< b, unsigned int N = 10000){ //generate a plane wave decomposition for the beam std::vector< planewave > pw_list = b.mc(N); //calculate the reflected and refracted waves for each incident wave for(unsigned int w = 0; w < pw_list.size(); w++){ incident(pw_list[w]); } } std::string str(){ std::stringstream ss; ss<<"Half Space-------------"< (rts::efield &ef, rts::halfspace hs); }; } #endif