Spherical Law of Cosines for Sides Calculator
This spherical law of cosines for sides calculator finds the unknown third side of a spherical triangle when two side arcs and their included angle are known.
Run — free
Enter all three measurements in degrees, and the result is returned as an angular arc in degrees on the sphere. It is useful for navigation, geodesy, astronomy, and geometry problems where an ordinary flat-triangle cosine rule would introduce error. The calculation is deterministic, runs without external data, and uses the standard spherical cosine relationship.
Enter sides as angular arcs, not linear distances
A side of a spherical triangle is a portion of a great circle, so this calculator expects each known side as a central angle in degrees. Enter the first arc as side_a_degrees and the second as side_b_degrees. Each must be greater than zero and less than 180 degrees. If your source gives a surface distance instead, convert that distance to an angular arc before calculating: divide the distance by the sphere radius to obtain radians, then convert radians to degrees. Use one consistent sphere radius for both sides. On Earth, the radius chosen depends on whether your task assumes a mean sphere or a particular reference model. This tool performs spherical geometry, not ellipsoidal geodesics, so it does not accept latitude and longitude or infer a radius. Keeping the distinction between linear distance and angular arc prevents the most common input mistake and makes the returned third side directly comparable with the two supplied sides. The result can later be converted back to distance by changing it to radians and multiplying by the same radius.
Use the angle between the two known sides
The included angle is the interior angle at the vertex where the two known side arcs meet. It is not an initial compass bearing, a central angle describing either side, or one of the triangle's other vertex angles. Supply it through included_angle_degrees, again strictly between zero and 180 degrees. The calculator converts all three inputs to radians and evaluates cos(c) = cos(a) cos(b) + sin(a) sin(b) cos(C). It then applies arccos to recover c and reports that shorter great-circle arc in degrees. Because floating-point arithmetic can place a theoretically valid cosine a tiny amount outside the interval from minus one to one, the implementation safely clamps that intermediate value before arccos. This is a numerical safeguard rather than a change to the formula. The output is rounded to twelve decimal places for stable, useful JSON while retaining far more precision than most practical measurements justify. Always keep enough significant figures in the inputs; apparent computational precision cannot replace the accuracy of the observations used to define the triangle.
Interpret the answer within a spherical model
The returned side_c_degrees is an arc angle in the closed range from zero to 180 degrees. For ordinary nondegenerate inputs it is the third minor great-circle side opposite the supplied included angle. You can use it directly in another spherical-trigonometry calculation or turn it into a surface length with distance = radius × side_c_radians. The result should not be substituted blindly for a high-accuracy terrestrial geodesic. Earth is not a perfect sphere, and long routes or surveying work may require an ellipsoidal inverse or direct solution. The calculator is best suited to textbook spherical triangles, approximate global navigation, celestial-sphere work, and models that explicitly define a sphere. It also differs from the planar law of cosines: even though both formulas use two sides and an included angle, spherical side lengths are themselves angles and the curvature term matters. As a quick reasonableness check, symmetric inputs often produce symmetric-looking results, while a very small spherical triangle approaches the familiar planar behavior. Invalid boundaries, missing values, text values, NaN, and infinity are rejected instead of producing a misleading arc.
What you can do with it
Great-circle navigation exercises
Find a missing route arc when two great-circle legs and the angle between them are known on a spherical Earth model.
Celestial sphere geometry
Solve the third angular separation in a spherical triangle formed by directions or coordinate poles on the sky.
Geodesy and education
Check spherical-trigonometry coursework or obtain a transparent baseline before applying a more detailed ellipsoidal method.
FAQ
What does the calculator return?
It returns side_c_degrees, the third side as a great-circle arc angle in degrees, together with the validated inputs.
What does one API request cost?
One API request costs $0.002. The browser calculator can be used free of charge.
Can I enter kilometers or miles for the sides?
No. Convert each distance to an angular arc using the sphere radius first, then enter that arc in degrees.
Which angle is the included angle?
It is the interior vertex angle where side a and side b meet, opposite the unknown side c.
Does this calculate an ellipsoidal Earth geodesic?
No. It uses an exact spherical formula. Precision navigation and surveying on Earth may require an ellipsoidal model.
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/spherical-law-of-cosines-side \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"side_a_degrees":60,"side_b_degrees":80,"included_angle_degrees":70}'const res = await fetch("https://api.kit.forhosting.com/trig/spherical-law-of-cosines-side", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"side_a_degrees": 60,
"side_b_degrees": 80,
"included_angle_degrees": 70
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/trig/spherical-law-of-cosines-side",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"side_a_degrees": 60,
"side_b_degrees": 80,
"included_angle_degrees": 70
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/trig/spherical-law-of-cosines-side", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"side_a_degrees":60,"side_b_degrees":80,"included_angle_degrees":70}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"side_a_degrees":60,"side_b_degrees":80,"included_angle_degrees":70}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/trig/spherical-law-of-cosines-side", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"side_a_degrees": 60,
"side_b_degrees": 80,
"included_angle_degrees": 70
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "trig.spherical_law_of_cosines_side",
"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. |