Law Of Cosines Interactive Calculator

← Back to Engineering Library

If you’re dealing with a triangle that isn’t a right triangle—whether you’re measuring a property, designing a linkage, or laying out a roof—the Pythagorean theorem isn’t going to cut it, but the Law of Cosines will. This calculator lets you work out missing triangle sides or angles using any combination of known lengths and angles. You’ll see this math turn up anywhere from mechanical linkage design to survey layouts and some structural engineering checks. On this page you’ll find the main formulas, a step-by-step example, detailed theory, and a practical FAQ.

What is the Law of Cosines?

The Law of Cosines gives you a way to relate all three sides of a triangle to one angle—even when there’s no right angle anywhere in sight. If you have two sides and the angle between them, or if you have all three sides, you can work out whatever you’re missing.

Simple Explanation

It’s the next step up from the Pythagorean theorem, but for any triangle. If you’ve got two sides and the angle connecting them, or all three sides, everything else about the triangle can be calculated. Surveyors, for instance, rely on this when direct measurement isn’t possible.

📐 Browse all 1000+ Interactive Calculators

How to Use This Calculator

  1. Pick what you want to solve—side or angle—using the dropdown.
  2. Type in the sides you already know (a, b, c) where prompted for your mode.
  3. Fill in the angle (in degrees) if your calculation requires it.
  4. Hit Calculate to see the result.

Triangle Diagram

Law Of Cosines Interactive Calculator Technical Diagram

Law of Cosines Interactive Calculator

Engineering calculation notice

This calculator is intended for education, concept evaluation, and preliminary design. Results are based on the equations and assumptions described on this page, but cannot account for every real-world load case, tolerance, material property, environmental condition, installation detail, safety factor, code, or regulatory requirement. Verify all inputs, assumptions, units, and results independently before selecting components or using the result in a real application. Safety-critical, structural, medical, lifting, transportation, or regulated applications must be reviewed by a qualified engineer.

Found a calculation error? Message us

Law of Cosines Interactive Visualizer

Move the sliders to see how changes to the sides or angle affect the triangle’s size and shape. All the relevant dimensions update at once.

Side a (units) 70
Side b (units) 100
Angle C (degrees) 60°

SIDE C

88.9

ANGLE A

46.6°

ANGLE B

73.4°

AREA

3031

FIRGELLI Automations — Interactive Engineering Calculators

Core Equations

If you know two sides and the angle between them, use this formula to find the third side:

Law of Cosines - Side Form

c² = a² + b² - 2ab·cos(C)

a² = b² + c² - 2bc·cos(A)

b² = a² + c² - 2ac·cos(B)

Where:
a, b, c = side lengths of the triangle (any consistent units)
A = angle opposite side a (degrees or radians)
B = angle opposite side b (degrees or radians)
C = angle opposite side c (degrees or radians)

For finding an angle when all three sides are known, use this:

Law of Cosines - Angle Form

cos(C) = (a² + b² - c²) / (2ab)

cos(A) = (b² + c² - a²) / (2bc)

cos(B) = (a² + c² - b²) / (2ac)

Application: Use these forms when all three sides are known and you need to find any angle. The arccosine function recovers the angle from the cosine ratio.

If you need the area and have all three sides, use Heron's formula:

Triangle Area - Heron's Formula

Area = √[s(s-a)(s-b)(s-c)]

Where:
s = semi-perimeter = (a + b + c) / 2 (units)
This formula calculates area using only the three side lengths, without requiring any angle measurements.

Simple Example

Mode: Solve for Side c. Inputs: a = 7, b = 10, Angle C = 60°.

c² = 7² + 10² − 2(7)(10)·cos(60°) = 49 + 100 − 140·(0.5) = 79

c = √79 ≈ 8.888 units

The calculator also returns triangle type (Acute), perimeter, and area automatically.

Theory & Engineering Applications

Mathematical Foundation and Derivation

The Law of Cosines extends the Pythagorean theorem to any triangle, not just right-angled ones. If angle C is 90°, the cosine term drops out and you’re back to c² = a² + b². The formula itself comes straight from vector subtraction—the difference between two side vectors gives you the third side, and the dot product ties it all together via the angle between them.

In practical calculation, watch out for very small or very large angles when solving for an angle with all three sides. As you approach angles near 0° or 180°, calculating cosine involves subtracting nearly equal numbers in the numerator, and this can wreck the significant digits on typical floating-point calculators. If you’re seeing inaccurate angle results for cases under 10°, it’s better to use the Law of Sines instead and work around the problem by subtracting from 180°, or as needed for the application. The same issue shows up for obtuse angles over 170°—the numbers get touchy there, too.

Coordinate System Derivation

If you set vertex C at the origin and lay side b along the x-axis, vertex B sits at (a, 0) and vertex A is at (b·cos(C), b·sin(C)). The third side c is just the distance between A and B, easily shown via good old distance formula and some trig identities to lead you right back to c² = a² + b² - 2ab·cos(C). This isn’t just theory—it’s the backbone behind CAD checks and geometric solutions.

Surveying and Geodetic Applications

Surveyors use the Law of Cosines every time the terrain stops them from measuring a triangle side directly. Two sight lines and their included angle give them the third, all without stepping foot on the part of property they can’t cross. When you’re mapping larger areas or dealing with Earth’s curve, you have to take it a step further and use the spherical law of cosines. That version is required once you’re working at 30 kilometers or more, because error from assuming a flat world quickly grows out of bounds.

On a sphere, the formula is cos(c/R) = cos(a/R)·cos(b/R) + sin(a/R)·sin(b/R)·cos(C), with a, b, c as arc lengths. If you’re doing GPS or serious mapping, you’ll run into this sooner or later.

Mechanical Linkage Analysis

If you’re laying out a four-bar linkage—found in everything from car suspensions to simple presses—the Law of Cosines is the tool for working out positions. Once you know your link lengths and crank angle, the equations sort out all the bar positions. As you sweep the input crank, you can keep track of where everything ends up through the cycle, and you’ll spot problems like lock-up before you even cut the first piece of material. It’s the standard way to get all the key angles and find out if your chosen dimensions will actually work through the whole motion range.

Force Vector Resolution in Structural Analysis

For engineering force problems, two forces meeting at a non-perpendicular angle don’t simply add up via the Pythagorean theorem. Instead, you get F_R² = F₁² + F₂² + 2F₁F₂·cos(θ), which is just the Law of Cosines. It’s a real timesaver when checking cable forces or truss loads, and helps you calculate both resultant force and its direction, even when the geometry gets awkward.

Navigation and GPS Triangulation

GPS position fixes rely on measuring the distance to satellites. The triangle between your receiver and any two satellites gives the Law of Cosines at work. While modern GPS always uses four satellites for altitude and redundancy, the fundamental horizontal calculation is plain triangle math. If satellites cluster, minor distance errors can snowball thanks to the law’s geometry—a reminder that the quality of your fix depends a lot on the sky layout as well as raw signal accuracy.

Loss of GPS precision in these cases is a practical limitation—sometimes the sensitivity makes a 5-meter error balloon to 50 meters or more, simply due to satellite placement.

Worked Example: Mechanical Linkage Design

Problem: We need a four-bar linkage for a windshield wiper. The pivots are 287.5 mm apart (the frame). The crank driven by the motor is 65 mm, and the output rocker needs to sweep 105°. The output arm length is 142 mm. What should the coupler length be? We’ll need to check that the design doesn’t produce a locked (dead-center) position that jams movement.

Solution:

Step 1: At crank angle θ = 0°, calculate the “diagonal” d₁ between the crank and rocker free ends:
d₁² = L₂² + L₁² - 2L₂L₁·cos(θ)
d₁² = 65² + 287.5² - 2(65)(287.5)·cos(0°)
d₁² = 49506.25
d₁ = 222.50 mm

Step 2: At maximum required sweep (rocker at 105°), repeat for d₂:
d₂² = L₂² + L₁² - 2L₂L₁·cos(105°)
d₂² = 96555.90
d₂ = 310.73 mm

Step 3: For both positions, check if the triangle (frame, rocker, diagonal) is possible. Compute the angle between rocker and diagonal at the start:
cos(α₁) = (L₁² + L₄² - d₁²) / (2L₁L₄)
α₁ = 49.26°

Step 4: Calculate the necessary coupler length:
L₃² = d₁² + L₄² - 2d₁L₄·cos(α₁)
L₃ = 168.59 mm

Step 5: Check the required geometry at maximum wiper sweep, recalculate the angle, and verify triangle construction at both ends.

Step 6: Triangle inequality: The coupler must be greater than |d₂ - L₄|, which it barely misses by 0.14 mm. Best to add a little margin—make L₃ = 170 mm. This ensures the linkage swings the full range without locking up.

Final Answer: A coupler length of 170 mm keeps the mechanism working properly and safely through the entire sweep. This saves trial-and-error in prototypes and gives you confidence before buying materials or starting the build.

This example spells out how the Law of Cosines isn’t just academic—it warns you of geometric trouble (like lock-up) before you’ve cut metal or spent money on parts. More calculators for mechanism and kinematics analysis can be found on the main engineering tools page.

Practical Applications

Scenario: Residential Property Boundary Dispute

When a surveyor can’t measure between two points directly because of obstacles—say, trees or fences—they’ll measure from both ends to a third visible marker and measure the angle between those sight lines. Plug those numbers into the Law of Cosines, and you have the missing distance without hacking your way through the brush. If you check it later by actually measuring, you’ll usually find it matches within the error of your instruments. This practical method saves field time and avoids unnecessary work.

Scenario: Robotics Competition Team Design

When building mechanisms, many teams run into the problem of not being able to reach a required position even after physically assembling their robot. By running the dimensions through the Law of Cosines calculator before cutting any material, you can find out if your four-bar linkage reaches the required targets or if you’re off by a few centimeters. Adjusting link lengths and re-running the calculator is much faster and cheaper than building and then discovering a geometry mistake late in a competition deadline.

Scenario: Marine Navigation During Coastal Fog

If radar tells you the distances and angle between two shore markers, you can use the Law of Cosines to check your calculated triangle against the actual charted distance between the landmarks. If your answer doesn’t match the map, it often points to sensor error (perhaps fouled equipment) or human error in measurement. This kind of cross-checking can confirm you’re on the right track—or give you early warning of a problem worth fixing before you proceed further.

Frequently Asked Questions

- When should I use the Law of Cosines instead of the Pythagorean theorem?

▼ Why does my calculator give an error when solving for an angle with certain side lengths?

▼ How accurate is the Law of Cosines for very small or very large angles?

▼ Can I use the Law of Cosines for three-dimensional problems?

▼ What's the relationship between the Law of Cosines and the dot product formula in vector analysis?

▼ How do I choose between using Law of Cosines and Law of Sines for a particular triangle problem?

Free Engineering Calculators

Explore our complete library of free engineering and physics calculators.

Browse All Calculators →

About the Author

Robbie Dickson — Chief Engineer & Founder, FIRGELLI Automations

Robbie Dickson brings over two decades of engineering expertise to FIRGELLI Automations. With a distinguished career at Rolls-Royce, BMW, and Ford, he has deep expertise in mechanical systems, actuator technology, and precision engineering.

Wikipedia · Full Bio

📹 Video Walkthrough — Law Of Cosines Interactive Calculator

📹 Video Walkthrough — Law Of Cosines Interactive Calculator

Law Of Cosines Interactive Calculator

Need to implement these calculations?

Explore the precision-engineered motion control solutions used by top engineers.

Share This Article
Tags