2021-04-11 17:00:38 +08:00
|
|
|
use na::{self, RealField};
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2019-03-23 21:29:07 +08:00
|
|
|
use crate::aliases::TVec;
|
2018-09-20 16:50:34 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise arc-cosinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn acos<T: RealField, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
x.map(|e| e.acos())
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic arc-cosinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn acosh<T: RealField, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
x.map(|e| e.acosh())
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise arc-sinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn asin<T: RealField, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
x.map(|e| e.asin())
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic arc-sinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn asinh<T: RealField, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
x.map(|e| e.asinh())
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise arc-tangent of `y / x`.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn atan2<T: RealField, const D: usize>(y: &TVec<T, D>, x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
y.zip_map(x, |y, x| y.atan2(x))
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise arc-tangent.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn atan<T: RealField, const D: usize>(y_over_x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
y_over_x.map(|e| e.atan())
|
|
|
|
}
|
2018-09-20 20:23:31 +08:00
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic arc-tangent.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn atanh<T: RealField, const D: usize>(x: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
x.map(|e| e.atanh())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise cosinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn cos<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.cos())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic cosinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn cosh<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.cosh())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise conversion from radians to degrees.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn degrees<T: RealField, const D: usize>(radians: &TVec<T, D>) -> TVec<T, D> {
|
|
|
|
radians.map(|e| e * na::convert(180.0) / T::pi())
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise conversion fro degrees to radians.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn radians<T: RealField, const D: usize>(degrees: &TVec<T, D>) -> TVec<T, D> {
|
|
|
|
degrees.map(|e| e * T::pi() / na::convert(180.0))
|
2018-09-20 16:50:34 +08:00
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise sinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn sin<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.sin())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic sinus.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn sinh<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.sinh())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise tangent.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn tan<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.tan())
|
|
|
|
}
|
|
|
|
|
2018-09-22 19:21:02 +08:00
|
|
|
/// Component-wise hyperbolic tangent.
|
2021-04-11 17:00:38 +08:00
|
|
|
pub fn tanh<T: RealField, const D: usize>(angle: &TVec<T, D>) -> TVec<T, D> {
|
2018-09-20 16:50:34 +08:00
|
|
|
angle.map(|e| e.tanh())
|
2018-09-20 20:23:31 +08:00
|
|
|
}
|