Skip to main content

trig/
lib.rs

1//! [![github]](https://github.com/tamaskis/trig) [![crates-io]](https://crates.io/crates/trig) [![docs-rs]](https://docs.rs/trig)
2//!
3//! [github]: https://img.shields.io/badge/github-8da0cb?style=for-the-badge&labelColor=555555&logo=github
4//! [crates-io]: https://img.shields.io/badge/crates.io-fc8d62?style=for-the-badge&labelColor=555555&logo=rust
5//! [docs-rs]: https://img.shields.io/badge/docs.rs-66c2a5?style=for-the-badge&labelColor=555555&logo=docs.rs
6//!
7//! Complete set of trigonometric and hyperbolic functions in Rust.
8//!
9//! # Summary
10//!
11//! This crate defines the [`Trig`] trait defining the complete set of trigonometric and hyperbolic
12//! functions. Rust already provides the following functions for [`f32`]s and [`f64`]s:
13//!
14//! * trigonometric functions (radians): `sin`, `cos`, `tan`
15//! * inverse trigonometric functions (radians): `asin`, `acos`, `atan`, `atan2`
16//! * hyperbolic functions: `sinh`, `cosh`, `tanh`
17//! * inverse hyperbolic functions: `asinh`, `acosh`, `atanh`
18//!
19//! In addition to these functions, the [`Trig`] trait also defines the reciprocal functions and
20//! their inverses for both the trigonometric and hyperbolic functions. The complete set of methods
21//! defined on the [`Trig`] trait is:
22//!
23//! * trigonometric functions (radians): `sin`, `cos`, `tan`, `csc`, `sec`, `cot`
24//! * inverse trigonometric functions (radians): `asin`, `acos`, `atan`, `acsc`, `asec`, `acot`
25//! * trigonometric functions (degrees): `sind`, `cosd`, `tand`, `cscd`, `secd`, `cotd`
26//! * inverse trigonometric functions (degrees): `asind`, `acosd`, `atand`, `atan2d`, `acscd`,
27//!   `asecd`, `acotd`
28//! * hyperbolic functions: `sinh`, `cosh`, `tanh`, `csch`, `sech`, `coth`
29//! * inverse hyperbolic functions: `asinh`, `acosh`, `atanh`, `acsch`, `asech`, `acoth`
30//! * unit conversions: `deg2rad`, `rad2deg`
31//!
32//! # Implementations
33//!
34//! This crate currently implements the [`Trig`] trait for the following types/structs:
35//!
36//! * [`f32`]
37//! * [`f64`]
38//!
39//! # Example
40//!
41//! ```
42//! use trig::Trig;
43//!
44//! let x = std::f64::consts::FRAC_PI_2;
45//! let abs_difference = (x.csc() - 1.0).abs();
46//!
47//! assert!(abs_difference < 1e-16);
48//! ```
49
50// Linter setup.
51#![warn(missing_docs, warnings, clippy::all, clippy::pedantic, clippy::cargo)]
52#![allow(clippy::float_cmp, clippy::unreadable_literal)]
53
54// Module declarations.
55pub(crate) mod f32_impl;
56pub(crate) mod f64_impl;
57pub(crate) mod trig_trait;
58
59// Re-exports.
60pub use crate::trig_trait::Trig;