From 97ca009bb841902e00ff5cdfdf77459f47d088ef Mon Sep 17 00:00:00 2001 From: klMse <61806749+klMse@users.noreply.github.com> Date: Wed, 6 Sep 2023 14:27:44 +0200 Subject: [PATCH] Fix arguments for hyberbolic functions (#2072) --- crates/typst-library/src/compute/calc.rs | 48 ++++++++---------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/crates/typst-library/src/compute/calc.rs b/crates/typst-library/src/compute/calc.rs index 7cfe24919..83ecac5d6 100644 --- a/crates/typst-library/src/compute/calc.rs +++ b/crates/typst-library/src/compute/calc.rs @@ -356,76 +356,58 @@ pub fn atan2( Angle::rad(f64::atan2(y.float(), x.float())) } -/// Calculates the hyperbolic sine of an angle. -/// -/// When called with an integer or a float, they will be interpreted as radians. +/// Calculates the hyperbolic sine of a hyperbolic angle. /// /// ## Example { #example } /// ```example /// #calc.sinh(0) \ -/// #calc.sinh(45deg) +/// #calc.sinh(1.5) /// ``` /// /// Display: Hyperbolic sine /// Category: calculate #[func] pub fn sinh( - /// The angle whose hyperbolic sine to calculate. - angle: AngleLike, + /// The hyperbolic angle whose hyperbolic sine to calculate. + value: f64, ) -> f64 { - match angle { - AngleLike::Angle(a) => a.to_rad().sinh(), - AngleLike::Int(n) => (n as f64).sinh(), - AngleLike::Float(n) => n.sinh(), - } + value.sinh() } -/// Calculates the hyperbolic cosine of an angle. -/// -/// When called with an integer or a float, they will be interpreted as radians. +/// Calculates the hyperbolic cosine of a hyperbolic angle. /// /// ## Example { #example } /// ```example /// #calc.cosh(0) \ -/// #calc.cosh(45deg) +/// #calc.cosh(1.5) /// ``` /// /// Display: Hyperbolic cosine /// Category: calculate #[func] pub fn cosh( - /// The angle whose hyperbolic cosine to calculate. - angle: AngleLike, + /// The hyperbolic angle whose hyperbolic cosine to calculate. + value: f64, ) -> f64 { - match angle { - AngleLike::Angle(a) => a.to_rad().cosh(), - AngleLike::Int(n) => (n as f64).cosh(), - AngleLike::Float(n) => n.cosh(), - } + value.cosh() } -/// Calculates the hyperbolic tangent of an angle. -/// -/// When called with an integer or a float, they will be interpreted as radians. +/// Calculates the hyperbolic tangent of an hyperbolic angle. /// /// ## Example { #example } /// ```example /// #calc.tanh(0) \ -/// #calc.tanh(45deg) +/// #calc.tanh(1.5) /// ``` /// /// Display: Hyperbolic tangent /// Category: calculate #[func] pub fn tanh( - /// The angle whose hyperbolic tangent to calculate. - angle: AngleLike, + /// The hyperbolic angle whose hyperbolic tangent to calculate. + value: f64, ) -> f64 { - match angle { - AngleLike::Angle(a) => a.to_rad().tanh(), - AngleLike::Int(n) => (n as f64).tanh(), - AngleLike::Float(n) => n.tanh(), - } + value.tanh() } /// Calculates the logarithm of a number.