snells_law_kernel

Function snells_law_kernel 

Source
pub fn snells_law_kernel(
    n1: IndexOfRefraction,
    n2: IndexOfRefraction,
    theta1: RayAngle,
) -> Result<RayAngle, PhysicsError>
Expand description

Calculates refracted angle using Snell’s Law or returns a Critical Angle error.

$$ n_1 \sin \theta_1 = n_2 \sin \theta_2 $$

§Arguments

  • n1 - Refractive index of medium 1.
  • n2 - Refractive index of medium 2.
  • theta1 - Angle of incidence (relative to normal).

§Returns

  • Result<RayAngle, PhysicsError> - Angle of refraction.

§Errors

  • PhysicalInvariantBroken - If total internal reflection occurs ($\sin \theta_2 > 1$).