Spherical mirror object distance calculator
This spherical mirror object distance calculator rearranges the mirror equation to find where an object must be placed for a chosen image distance.
Run — free
Runs in your browser. Free, unlimited — your data never leaves this page.
Enter the focal length and desired image distance in any consistent length unit, using the standard sign convention, and receive the required object distance in that same unit. It works for concave and convex spherical mirrors, identifies combinations that imply an object at infinity, and provides a fast check for classroom optics, laboratory setups, and early optical design calculations.
Enter distances with one consistent sign convention
The calculator uses the common real-is-positive convention for spherical mirrors. Give a concave mirror a positive focal length and a convex mirror a negative focal length. Enter a positive image distance when reflected rays actually converge to form a real image in front of the mirror, or a negative image distance when the image is virtual and appears behind the mirror. Both inputs must use the same physical unit, such as millimeters, centimeters, or meters; because the equation is homogeneous, the result automatically uses that unit too. Do not mix centimeters for focal length with millimeters for image distance unless you convert one first. A sign is part of the measurement, not merely a display preference, so changing it changes the physical arrangement being requested. The calculator accepts decimal values and numeric strings through the API, but both distances must be finite and non-zero. Keeping a quick sketch of the mirror, object side, and image side beside your values is often the simplest way to prevent a sign mistake before calculating.
How the object distance is calculated
A spherical mirror obeys 1/f = 1/do + 1/di, where f is focal length, do is object distance, and di is image distance. Solving specifically for the unknown object distance gives do = f × di / (di − f). This capability applies that rearrangement directly, after validating that the two supplied quantities describe a finite calculation. When image distance equals focal length, the denominator becomes zero. Physically, that limiting case places the object infinitely far away, so there is no finite object distance to return and the calculator reports an input error. Zero focal length and zero image distance are also rejected because the reciprocal form of the mirror equation is undefined there. The result retains its algebraic sign. A positive object distance normally describes a real object in front of the mirror, while a negative result describes a virtual object under the selected convention. Floating-point output is normalized to stable significant precision, making repeated API and browser calculations deterministic while retaining useful accuracy for ordinary optics work.
Interpret the result and check the setup
Treat the returned object distance as the position required by the ideal paraxial mirror model. Its magnitude tells you how far from the mirror vertex to place the object, and its sign tells you which side is implied by the convention. For example, a concave mirror with a positive focal length can produce a positive object distance for many real-image targets. Substituting the returned value into the original equation is a useful independent check: 1/f should equal 1/do + 1/di within normal rounding. The calculation assumes a spherical mirror, rays near the principal axis, negligible mirror thickness, and a focal length that is already known. It does not model spherical aberration, aperture limits, tilted mirrors, wavelength-dependent coatings, or mechanical clearance. Those effects matter in precision systems and should be evaluated with a fuller ray-tracing model. For teaching, bench planning, and quick feasibility checks, however, the ideal equation clearly shows whether the requested image position corresponds to a finite object placement and whether that placement is real or virtual.
What you can do with it
Plan a concave-mirror demonstration
Find where to place an illuminated object so its real image lands on a screen at a chosen distance.
Check an optics homework result
Solve the mirror equation for object distance and verify both the magnitude and sign against a ray diagram.
Estimate a laboratory bench layout
Test whether a desired image plane implies a practical finite object position before arranging mounts and targets.
FAQ
What does the calculation cost?
The API price is $0.002 per calculation. The browser calculator is free to run on this page.
Which units should I use?
Use any length unit, but use the same unit for focal length and image distance. The object distance is returned in that unit.
Why can the object distance be negative?
Under the real-is-positive convention, a negative object distance represents a virtual object rather than a real object placed in front of the mirror.
Why is image distance equal to focal length rejected?
That makes the rearranged equation's denominator zero and corresponds to an object at infinity, not a finite placement.
Does this work for concave and convex mirrors?
Yes. Use a positive focal length for a concave mirror and a negative focal length for a convex mirror under the stated convention.
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/mirror-object-distance \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"focal_length":10,"image_distance":30}'const res = await fetch("https://api.kit.forhosting.com/optics/mirror-object-distance", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"focal_length": 10,
"image_distance": 30
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/optics/mirror-object-distance",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"focal_length": 10,
"image_distance": 30
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/optics/mirror-object-distance", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"focal_length":10,"image_distance":30}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"focal_length":10,"image_distance":30}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/optics/mirror-object-distance", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"focal_length": 10,
"image_distance": 30
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "optics.mirror_object_distance",
"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. |