From 031ee04a1c0d8ab24500ad3572e48811d3b7878a Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Thu, 4 Jul 2024 10:39:26 +0100 Subject: [PATCH] docs: "Radians and degrees support" added --- .../dimensionless_quantities.md | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/docs/users_guide/framework_basics/dimensionless_quantities.md b/docs/users_guide/framework_basics/dimensionless_quantities.md index 3f0aac07..695e6fb1 100644 --- a/docs/users_guide/framework_basics/dimensionless_quantities.md +++ b/docs/users_guide/framework_basics/dimensionless_quantities.md @@ -186,6 +186,40 @@ that both _angular measure_ and _solid angular measure_ should also be proposals submitted to make an angle a base quantity and `rad` to become a base unit. More on this topic can be found in the ["Strong Angular System" chapter](../systems/strong_angular_system.md). +### Radians and degrees support + +Thanks to the usage of magnitudes the library provides efficient strong types for all angular +types. This means that with the built-in support for magnitudes of $\pi$ we can provide accurate +conversions between radians and degrees. The library also provides common trigonometric functions +for angular quantities: + +```cpp +quantity speed = 110 * km / h; +quantity rate_of_climb = -0.63657 * m / s; +quantity glide_ratio = speed / -rate_of_climb; +quantity glide_angle = angular::asin(1 / glide_ratio); + +std::println("Glide ratio: {::N[.1f]}\n", value_cast(glide_ratio)); +std::println("Glide angle:"); +std::println(" - {::N[.4f]}\n", glide_angle); +std::println(" - {::N[.2f]}\n", value_cast(glide_angle)); +std::println(" - {::N[.2f]}\n", value_cast(glide_angle)); +``` + +The above program prints: + +```text +Glide ratio: 48.0 +Glide angle: + - 0.0208 rad + - 1.19° + - 1.33ᵍ +``` + +!!! note + + In the production code the above `speed` and `rate_of_climb` quantities should probably be + modelled as [separate typed quantities of the same kind](systems_of_quantities.md#system-of-quantities-is-not-only-about-kinds). ## Nested quantity kinds