The Law of Cosines gives us a formula for solving a triangle given two sides and the angle between them. An excellent real-world application is describing the linear position of a piston as a function of the angle of rotation of a crankshaft. The piston is connected to the crankshaft by a connecting rod. A triangle is formed by the radius from the center of the crankshft to one end of the rod; the rod itself; and the imaginary line forming the changing distance between the center of the crankshaft and the piston.
In certain machinery applications, the crankshaft drives the piston. In a car engine (shown here), the piston drives the crankshaft. When the piston is farthest from the crankshaft, a sparkplug ignites a gasoline/air mixture. The explosion forces the piston to move down the cylinder, pushing on the rod and thereby driving the crankshaft. Several pistons (usually 4, 6, or 8) work together, though out of phase with each other to create smooth and even motion over the entire rotation cycle of the crankshaft.

Click the PLAY button to start the animation, or manually drag the "rotation" slider to set the angle of crankshaft rotation (measured in radians). Observe how the position "d" of the piston changes as the crankshft rotates. At the top of the screen is shown the Law of Cosines formula for this configuration. We can solve this for "d" as a function of Θ, d(Θ), since we know two sides of the triangle and one angle. As it turns out, solving the Law of Cosines results ina quadratic in d, and so the solution is made using the quadratic formula.