Angle of refraction calculator
Going from index 1 into glass of 1.5 at 30°, a ray refracts to 19.4712206345° and turns by 10.5287793655°. Enter the incidence angle, in degrees or radians, and both indices; you also get the critical angle when one exists. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- Incidence angle
- 30
- N1
- 1
- N2
- 1.5
- Angle unit
- deg degrees
- Incidence angle deg
- 30
- Refraction angle deg
- 19.4712206345
- Refraction angle rad
- 0.3398369095
The angle of refraction calculator applies Snell's law to any pair of transparent media. You provide the incidence angle — in degrees or radians, measured from the surface normal — together with the refractive index of the medium the ray leaves and of the medium it enters, and you get back the refraction angle in degrees, the deviation the ray suffers at the boundary, and the critical angle whenever one exists.
What the angle of refraction is
When a ray of light crosses the boundary between two transparent media — air into water, water into glass, glass into air — its speed changes, and because its speed changes its direction changes too. The new direction, measured from the line perpendicular to the surface at the point of entry, is the angle of refraction. It is not arbitrary: Snell's law fixes it exactly through the relation n₁·sin(θ₁) = n₂·sin(θ₂), where n₁ and n₂ are the refractive indices of the two media and θ₁ is the incidence angle.
A ray entering a denser medium (n₂ greater than n₁) bends toward the normal and the refraction angle comes out smaller than the incidence angle; a ray entering a less dense medium bends away from the normal and the refraction angle is larger. At normal incidence, θ₁ equal to zero, the ray passes straight through with no bending at all, whatever the indices are.
The result is deterministic — the same three numbers always produce the same answer — so it is safe to use inside physics engines, rendering code and grading tools.
The critical angle and total internal reflection
Snell's law has a geometric limit. When light travels from a denser medium into a less dense one (n₁ greater than n₂), the refraction angle is always larger than the incidence angle, and there is a specific incidence angle at which the refracted ray would have to travel exactly along the surface: the critical angle, arcsin(n₂/n₁). Beyond it, sin(θ₂) would have to exceed one, which is impossible, so no refracted ray exists and all the light is reflected back — total internal reflection.
This is the principle behind optical fibers, diamond brilliance and the mirror-like underside of the water surface seen by a diver. Many calculators silently return NaN in this regime, or clamp the result and hand back a wrong-looking but plausible number. When n₁ is greater than n₂, the response also includes the critical angle in degrees, so you can check how close to the limit a given configuration sits without a second call.
What you can do with it
Check a physics exercise
Verify a Snell's law homework answer: send the incidence angle and both indices and compare the returned refraction angle with the worked solution.
Drive a ray tracer
Feed the refraction direction of a glass or water surface in a renderer, and rely on the critical-angle error to switch to total internal reflection.
Design a fiber-optic link
Confirm a launch configuration stays below the critical angle at the core-cladding boundary by reading the critical angle reported in the same response.
FAQ
Which unit is the refraction angle returned in?
Always in degrees, with a radians copy alongside.
Which refractive indices should I use?
Any positive numbers. Vacuum is exactly 1, air about 1.0003, water about 1.333, crown glass about 1.52, diamond about 2.417.
Are the results deterministic?
Yes. It is a closed-form evaluation of Snell's law with no randomness, no network and no clock, rounded to 12 significant digits for byte-stable output.
What is the deviation angle?
It is how much the ray changes direction at the boundary, the difference between the incidence and refraction angles. A ray at 30° going from index 1 into glass of 1.5 is deviated by 10.5287793655°.
When does the result include a critical angle?
Whenever light travels from a denser medium into a less dense one, so the first index is larger than the second. The critical angle shows how close your incidence angle is to total internal reflection, without a second calculation.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/phys/angle-of-refraction \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"incidence_angle":30,"n1":1,"n2":1.5}'const res = await fetch("https://api.kit.forhosting.com/phys/angle-of-refraction", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"incidence_angle": 30,
"n1": 1,
"n2": 1.5
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/phys/angle-of-refraction",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"incidence_angle": 30,
"n1": 1,
"n2": 1.5
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/phys/angle-of-refraction", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"incidence_angle":30,"n1":1,"n2":1.5}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"incidence_angle":30,"n1":1,"n2":1.5}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/phys/angle-of-refraction", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"incidence_angle": 30,
"n1": 1,
"n2": 1.5
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "phys.angle_of_refraction",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
When the incidence angle exceeds the critical angle, the call tells you so instead of returning a meaningless number.
What the angle of refraction is
This endpoint solves that equation directly: you send the incidence angle and the two indices and receive θ₂ in degrees, with a radians copy for callers that work in radians natively.
The critical angle and total internal reflection
This endpoint treats it as an explicit error: the message names the incidence angle, both indices and the computed sine, so an automated caller can detect the condition and switch to a reflection path instead of consuming garbage.
Inputs, outputs and practical use
Typical uses include verifying homework solutions, precomputing lookup tables for underwater photography rigs, driving the refractive component of a ray tracer, and sizing fiber-optic links where staying under the critical angle is the whole design constraint. The call takes three required fields and one optional one. incidence_angle is the angle from the surface normal; by default it is read as degrees and must lie between 0 and 90, and setting angle_unit to rad switches it to radians with a range of 0 to π/2. n1 and n2 are the refractive indices of the incident and refracted media — vacuum is exactly 1, air is about 1.0003, water about 1.333, common crown glass about 1.52 and diamond about 2.417. The response returns both indices as received, the incidence angle normalised to degrees, the refraction angle in degrees and in radians, and the deviation — how many degrees the boundary actually steered the ray — which is often the number a lens designer or game developer wants next. It costs $0.002 per request through the API and runs free in the browser on this page, with identical results in both.
Technical questions
What does it cost?
$0.002 per request via the API. It is also free to run in your browser on this page, with the same deterministic result.
What happens beyond the critical angle?
The call returns an invalid_input error explaining that no refraction angle exists, with the indices and the computed sine, instead of returning NaN or a clamped number.
Does it report the critical angle?
Yes. Whenever n1 is greater than n2, the response includes critical_angle_deg = arcsin(n2/n1) so you can see the total-internal-reflection threshold.