diagram_core/src/formula/math.rs#
Source: lib/diagram_core/src/formula/math.rs
math -- the float functions formulas need, without std and without libm
Accurate to a few units in the last place over the ranges drawings use (angles of a few
turns, lengths up to kilometres): range reduction, then series on a small interval. The
engine compares results with the values Visio stored, so plain truncated series that lose
digits are not good enough; these keep about 15 significant digits.
fn floor(x: f64) -> f64largest integer not above xfn ceil(x: f64) -> f64smallest integer not below xfn trunc(x: f64) -> f64x without its fractionfn round(x: f64) -> f64x rounded half away from zerofn sqrt(x: f64) -> f64the square root (NaN below 0)fn pow2(e: i64) -> f642^e for integer e (exact while the result is a normal number)fn sincos(x: f64) -> (f64, f64)sine and cosinefn sin(x: f64) -> f64sinefn cos(x: f64) -> f64cosinefn tan(x: f64) -> f64tangentfn atan(x: f64) -> f64arc tangentfn atan2(y: f64, x: f64) -> f64the angle of (x, y): atan2(y, x) in -pi ..= pifn asin(x: f64) -> f64arc sine (NaN outside -1..1)fn acos(x: f64) -> f64arc cosine (NaN outside -1..1)fn exp(x: f64) -> f64e^xfn ln(x: f64) -> f64the natural logarithm (NaN below 0, -inf at 0)fn log10(x: f64) -> f64the logarithm to base 10fn pow(x: f64, y: f64) -> f64x to the power y (integer y by repeated squaring, exactly as Visio's ^2 needs)fn sinh(x: f64) -> f64hyperbolic sine, cosine, tangentfn cosh(x: f64) -> f64hyperbolic cosinefn tanh(x: f64) -> f64hyperbolic tangentfn modulus(x: f64, y: f64) -> f64x modulo y with the sign of y (Visio's MODULUS); NaN for y = 0