Grating wavelength from angle calculator
This grating wavelength from angle calculator finds the wavelength associated with a measured diffraction angle.
Run — free
Enter the spacing between adjacent grating lines, the signed angle measured from the grating normal, and the signed nonzero diffraction order. The calculator rearranges the normal-incidence grating equation, d sin(theta) = m lambda, and returns wavelength in the same length unit used for spacing. It also shows the radian angle, sine value, formula, and substitution steps so the result can be checked or recorded.
Enter line spacing, angle, and order consistently
Begin with the physical spacing d between neighboring lines on the grating. You may enter metres, millimetres, micrometres, nanometres, or another length unit, because the calculation is scale-neutral: the returned wavelength uses exactly the same unit as the spacing. Do not enter a groove density directly. If a grating is specified in lines per millimetre, first take the reciprocal to obtain millimetres per line. Next enter the diffraction angle in degrees, measured from the normal to the grating rather than from its surface. The angle is signed, as is the diffraction order. A positive angle belongs with a positive order and a negative angle with a negative order. Their matching signs make the calculated wavelength positive. The order must be a nonzero integer because the zero-order beam is not wavelength-separated and therefore cannot determine wavelength through this rearrangement. These conventions assume normal incidence, meaning the incoming beam follows the grating normal. If the source arrives obliquely, use the generalized grating equation instead of treating its incidence angle as zero.
Understand the rearranged grating equation
For normal incidence, a transmission or reflection grating is described by d sin(theta) = m lambda, where d is line spacing, theta is the diffraction angle, m is the integer order, and lambda is wavelength. Solving for the requested quantity gives lambda = d sin(theta) / m. The calculator converts the supplied degree angle to radians before evaluating the sine, then multiplies that dimensionless sine by the spacing and divides by the order. Because sine carries no unit and order is a pure integer, wavelength inherits the spacing unit. This unit behavior is useful for quick laboratory work: a spacing entered in micrometres produces a wavelength in micrometres without an extra conversion. The signs encode which side of the grating normal contains a diffracted order. Negative angle with negative order gives the same positive wavelength as the corresponding positive pair. An angle of zero cannot yield a positive wavelength for a nonzero order, so it is rejected. Angles are restricted to the physical principal range from minus ninety through plus ninety degrees.
Check assumptions and interpret the result
Use the returned steps to verify both the numerical substitution and the experimental assumptions. First confirm that the reported sine has the expected magnitude and sign. Then check that the wavelength scale makes sense relative to the spacing: since the absolute sine cannot exceed one, the wavelength cannot exceed d divided by the absolute order under this model. A result near that upper bound corresponds to diffraction near grazing angle, where small angular measurement errors can strongly affect inferred wavelength. The calculation describes ideal geometric diffraction and does not estimate intensity, resolving power, blaze efficiency, polarization response, finite slit width, or uncertainty. It also does not decide whether a detector can observe the resulting wavelength. For measured data, retain the angle convention, grating specification, order assignment, and spacing unit alongside the answer. If you know groove density rather than spacing, document the reciprocal conversion. If the incident beam is not normal to the grating, if the medium has a relevant refractive index, or if the optical arrangement uses a different sign convention, adapt the governing equation before relying on this result.
What you can do with it
Identify a spectral line
Convert a measured detector angle into a candidate wavelength for a known grating spacing and diffraction order.
Check a spectrometer setup
Confirm that an expected wavelength should appear at the observed signed angle in the selected order.
Analyze a teaching experiment
Show the rearrangement and substitution used to infer wavelength from diffraction measurements.
FAQ
Which grating equation does this calculator use?
It uses d sin(theta) = m lambda for normal incidence and rearranges it to lambda = d sin(theta) / m.
What unit is the wavelength returned in?
The wavelength is returned in the same length unit as the spacing. If spacing is in micrometres, wavelength is in micrometres.
Can I enter lines per millimetre as spacing?
No. Convert groove density to line spacing first by taking its reciprocal; lines per millimetre becomes millimetres per line.
Why must angle and order have matching signs?
Their signs identify the side of the normal. Matching nonzero signs make d sin(theta) divided by m a positive physical wavelength.
What does an API request cost?
The API price is $0.002 per request. The same deterministic calculation is also available in the browser.
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/optics/grating-wavelength-from-angle \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"spacing":0.001,"angle_deg":30,"order":1}'const res = await fetch("https://api.kit.forhosting.com/optics/grating-wavelength-from-angle", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"spacing": 0.001,
"angle_deg": 30,
"order": 1
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/grating-wavelength-from-angle",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"spacing": 0.001,
"angle_deg": 30,
"order": 1
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/grating-wavelength-from-angle", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"spacing":0.001,"angle_deg":30,"order":1}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"spacing":0.001,"angle_deg":30,"order":1}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/grating-wavelength-from-angle", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"spacing": 0.001,
"angle_deg": 30,
"order": 1
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.grating_wavelength_from_angle",
"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. |