The cosine function computes a trigonometric value from an angle. It turns measurements such as a lighthouse sighting into a value that can support navigation calculations, replacing printed tables with an executable calculation. section 3.1
Julia’s cosine workflow becomes safer when angle units are represented explicitly:
- Represent angles with Radian or DMS types instead of leaving the unit implicit. section 9.3
- Convert DMS values to radians before applying the underlying cosine calculation. section 9.3.5
- Define cos methods for both Radian and DMS values so callers cannot silently confuse degrees and radians. section 9.3.5
Cosine with explicit angle units
A unit-aware implementation delegates radians to Julia’s standard calculation and converts DMS values first: `cos(rad::Radian) = Base.cos(rad.radians)` and `cos(dms::DMS) = cos(Radian(dms))`. With these methods, cosine can accept `Radian(π/2)` or a DMS angle while keeping the unit visible. section 9.3.5
Figure 3.1 A captain on a ship could use a sextant to measure angle θ between the horizon and top of a lighthouse.
Use the lighthouse-and-sextant figure to connect cosine calculations with the practical problem of locating a ship from an observed angle. section 3.1


