1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use na::{self, DefaultAllocator, RealField};

use crate::aliases::TVec;
use crate::traits::{Alloc, Dimension};

/// Component-wise arc-cosinus.
pub fn acos<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    x.map(|e| e.acos())
}

/// Component-wise hyperbolic arc-cosinus.
pub fn acosh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    x.map(|e| e.acosh())
}

/// Component-wise arc-sinus.
pub fn asin<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    x.map(|e| e.asin())
}

/// Component-wise hyperbolic arc-sinus.
pub fn asinh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    x.map(|e| e.asinh())
}

/// Component-wise arc-tangent of `y / x`.
pub fn atan2<N: RealField, D: Dimension>(y: &TVec<N, D>, x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    y.zip_map(x, |y, x| y.atan2(x))
}

/// Component-wise arc-tangent.
pub fn atan<N: RealField, D: Dimension>(y_over_x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    y_over_x.map(|e| e.atan())
}

/// Component-wise hyperbolic arc-tangent.
pub fn atanh<N: RealField, D: Dimension>(x: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    x.map(|e| e.atanh())
}

/// Component-wise cosinus.
pub fn cos<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.cos())
}

/// Component-wise hyperbolic cosinus.
pub fn cosh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.cosh())
}

/// Component-wise conversion from radians to degrees.
pub fn degrees<N: RealField, D: Dimension>(radians: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    radians.map(|e| e * na::convert(180.0) / N::pi())
}

/// Component-wise conversion fro degrees to radians.
pub fn radians<N: RealField, D: Dimension>(degrees: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    degrees.map(|e| e * N::pi() / na::convert(180.0))
}

/// Component-wise sinus.
pub fn sin<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.sin())
}

/// Component-wise hyperbolic sinus.
pub fn sinh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.sinh())
}

/// Component-wise tangent.
pub fn tan<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.tan())
}

/// Component-wise hyperbolic tangent.
pub fn tanh<N: RealField, D: Dimension>(angle: &TVec<N, D>) -> TVec<N, D>
where
    DefaultAllocator: Alloc<N, D>,
{
    angle.map(|e| e.tanh())
}