Shadow length from sun angle calculator
This shadow length calculator finds how far the shadow of a vertical object extends across level ground when you know the object's height and the Sun's elevation angle.
Run — free
Enter the height in any length unit and the solar elevation in degrees above the horizon. The result uses the same unit as the height. It is a quick, deterministic way to plan shade, explore solar geometry, prepare a photograph, or check a right-triangle calculation without drawing the triangle by hand.
Enter a vertical height and a valid solar elevation
Start with the vertical height of the object that casts the shadow. You may use metres, feet, centimetres, inches, or another length unit because the calculator preserves that unit in the resulting shadow length. Measure from the point where the object meets the ground to its top, and make sure the object is upright. Then enter the Sun's elevation angle in degrees above the local horizon. The angle must be greater than zero and less than ninety degrees. An angle near zero describes sunlight close to the horizon and produces a very long theoretical shadow. An angle near ninety describes sunlight almost overhead and produces a very short one. Do not enter a zenith angle, compass bearing, or azimuth: those are different measurements. If a source gives the zenith angle instead, subtract it from ninety degrees before using this calculator. For meaningful field estimates, the ground should be approximately level and the shadow should fall without interruption from walls, trees, or changes in terrain.
Understand the cotangent relationship
A vertical object, its horizontal shadow, and a straight ray of sunlight form a right triangle in the simplified model. The object height is opposite the Sun's elevation angle, while the shadow is adjacent to that angle. Tangent therefore equals height divided by shadow length. Rearranging the equation gives shadow length equals height divided by the tangent of the elevation angle, which is also height multiplied by the cotangent of that angle. The calculator converts degrees to radians for the trigonometric operation and rounds the reported numeric values to twelve decimal places for stable machine-readable output. At forty-five degrees, tangent is one, so the shadow and object have equal lengths. Below forty-five degrees the shadow is longer than the object; above forty-five degrees it is shorter. The returned shadow-to-height ratio makes that relationship explicit and can be reused for several objects under the same sunlight. Doubling the height doubles the predicted shadow, while changing the angle affects every object through the same cotangent ratio.
Interpret the estimate and its practical limits
Treat the result as an ideal geometric estimate, not a surveyed boundary or a complete solar-position forecast. The model assumes a perfectly vertical object, level ground, straight incoming light, and a clearly defined ray from the top of the object. Real shadows may differ because the ground slopes, the object leans, the Sun has a visible disk rather than being a point, and atmospheric refraction matters near the horizon. A fuzzy shadow edge also makes physical measurement less exact than the decimal output suggests. The calculator does not determine the elevation angle from a date, time, latitude, or longitude; obtain that angle from an appropriate solar-position source and then use it here. For garden or photography planning, compare several plausible angles to see how shade changes during the day or season. For construction setbacks, solar access rules, surveying, navigation, or safety-critical work, use the standards, professional instruments, and tolerances required for that field. Never look directly at the Sun to estimate its angle; use published solar data or safe indirect measurement methods.
What you can do with it
Plan temporary shade
Estimate how far a pole, screen, or upright structure will cast shade at a known solar elevation.
Prepare an outdoor photograph
Predict the approximate reach of shadows when choosing a viewpoint and time for directional light.
Teach right-triangle geometry
Show how cotangent connects an elevation angle and an object's height to an adjacent shadow length.
FAQ
What formula does the calculator use?
It uses shadow length = height / tan(sun elevation angle), which is equivalent to height multiplied by cotangent.
What unit is the shadow length returned in?
It uses the same length unit as the height. If height is in metres, the shadow length is in metres.
Why must the angle be between 0 and 90 degrees?
Those bounds describe a Sun above the horizon without reaching the singular horizon case or the exactly overhead limit in this model.
Does the calculator account for sloped ground?
No. It assumes a vertical object standing on horizontal ground; slope requires a different geometric model.
Is sun elevation the same as azimuth?
No. Elevation is the angle above the horizon, while azimuth is the compass direction around the horizon.
What does an API calculation cost?
Each API request costs $0.002; the same deterministic calculation can run locally 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/trig/shadow-length \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"height":2,"sun_elevation_degrees":45}'const res = await fetch("https://api.kit.forhosting.com/trig/shadow-length", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"height": 2,
"sun_elevation_degrees": 45
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/trig/shadow-length",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"height": 2,
"sun_elevation_degrees": 45
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/trig/shadow-length", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"height":2,"sun_elevation_degrees":45}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"height":2,"sun_elevation_degrees":45}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/trig/shadow-length", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"height": 2,
"sun_elevation_degrees": 45
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "trig.shadow_length",
"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. |