Passing light through a wedge and a sphere

5 views (last 30 days)
a monochromatic beamm of light is passing through a glass wedge of a glass sphere, how to write MATLAB script file fot that, this is so necessary for my project.

Answers (1)

BhaTTa
BhaTTa on 18 Mar 2025
Hey @Hazrat Shah Rasouli, i assume that you want to simulate a monochromatic beam of light passing through a glass wedge of a glass sphere in MATLAB, you can use the principles of geometric optics. This involves calculating the refraction of light at the interfaces of the glass using Snell's law. Below is a basic framework for simulating this scenario in MATLAB.Assumptions:
  • The glass wedge is part of a sphere.
  • The light is monochromatic, meaning it has a single wavelength.
  • Refraction is calculated using Snell's law.
  • The glass has a known refractive index.
  • The sphere and light beam are in a 2D plane for simplicity.
Below I have attached code as an example, please take it as refercene and modify it accordingly
% Parameters
n_air = 1.0; % Refractive index of air
n_glass = 1.5; % Refractive index of glass
wavelength = 550e-9; % Wavelength of light in meters (e.g., green light)
radius = 1; % Radius of the glass sphere
angle_of_incidence = 30; % Angle of incidence in degrees
% Convert angle to radians
angle_of_incidence_rad = deg2rad(angle_of_incidence);
% Calculate angle of refraction using Snell's law
angle_of_refraction_rad = asin(n_air / n_glass * sin(angle_of_incidence_rad));
% Calculate the path of the light beam
% Assume the beam enters the sphere at the top and exits at the bottom
% Entering point
x_enter = 0;
y_enter = radius;
% Refracted path inside the sphere
x_refract = radius * sin(angle_of_refraction_rad);
y_refract = radius * cos(angle_of_refraction_rad);
% Exiting point (simplified, assuming it exits directly opposite)
x_exit = 0;
y_exit = -radius;
% Plotting
figure;
hold on;
% Plot the glass sphere
theta = linspace(0, 2*pi, 100);
x_sphere = radius * cos(theta);
y_sphere = radius * sin(theta);
plot(x_sphere, y_sphere, 'b-');
% Plot the incoming beam
plot([x_enter, x_refract], [y_enter, y_refract], 'r--', 'LineWidth', 2);
% Plot the refracted beam inside the sphere
plot([x_refract, x_exit], [y_refract, y_exit], 'g--', 'LineWidth', 2);
% Plot the exiting beam (simplified as a straight line)
plot([x_exit, x_exit], [y_exit, y_exit - 0.5], 'r--', 'LineWidth', 2);
% Annotate the plot
title('Refraction of Monochromatic Light Through a Glass Sphere');
xlabel('X Position');
ylabel('Y Position');
axis equal;
grid on;
legend('Glass Sphere', 'Incoming Beam', 'Refracted Beam', 'Exiting Beam');
hold off;

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!