Skip to content

Commit c22f1d7

Browse files
committed
Added more trigonometric functions
1 parent 09523fc commit c22f1d7

File tree

1 file changed

+83
-3
lines changed

1 file changed

+83
-3
lines changed

src/lib.rs

Lines changed: 83 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,32 @@ impl Sqrt for f64 {
224224

225225
/// Basic trigonometry functions
226226
pub trait Trig {
227-
/// Returns sine of self
227+
/// Returns sine of self.
228228
fn sin(self) -> Self;
229-
/// Returns cosine of self
229+
/// Returns cosine of self.
230230
fn cos(self) -> Self;
231-
/// Returns tangent of self
231+
/// Returns tangent of self.
232232
fn tan(self) -> Self;
233+
/// Returns inverse sine of self.
234+
fn asin(self) -> Self;
235+
/// Returns inverse cosine of self.
236+
fn acos(self) -> Self;
237+
/// Returns inverse tangent of self.
238+
fn atan(self) -> Self;
239+
/// Returns the four quadrant arctangent of self (y) and other (x).
240+
fn atan2(self, other: Self) -> Self;
241+
/// Returns hyperbolic sine of self.
242+
fn sinh(self) -> Self;
243+
/// Returns hyperbolic cosine of self.
244+
fn cosh(self) -> Self;
245+
/// Returns hyperbolic tangent of self.
246+
fn tanh(self) -> Self;
247+
/// Returns inverse hyperbolic sine of self.
248+
fn asinh(self) -> Self;
249+
/// Returns inverse hyperbolic cosine of self.
250+
fn acosh(self) -> Self;
251+
/// Returns inverse hyperbolic tangent of self.
252+
fn atanh(self) -> Self;
233253
}
234254

235255
impl Trig for f32 {
@@ -241,6 +261,36 @@ impl Trig for f32 {
241261

242262
#[inline(always)]
243263
fn tan(self) -> f32 { self.tan() }
264+
265+
#[inline(always)]
266+
fn asin(self) -> f32 { self.asin() }
267+
268+
#[inline(always)]
269+
fn acos(self) -> f32 { self.acos() }
270+
271+
#[inline(always)]
272+
fn atan(self) -> f32 { self.atan() }
273+
274+
#[inline(always)]
275+
fn atan2(self, other: f32) -> f32 { self.atan2(other) }
276+
277+
#[inline(always)]
278+
fn sinh(self) -> f32 { self.sinh() }
279+
280+
#[inline(always)]
281+
fn cosh(self) -> f32 { self.cosh() }
282+
283+
#[inline(always)]
284+
fn tanh(self) -> f32 { self.tanh() }
285+
286+
#[inline(always)]
287+
fn asinh(self) -> f32 { self.asinh() }
288+
289+
#[inline(always)]
290+
fn acosh(self) -> f32 { self.acosh() }
291+
292+
#[inline(always)]
293+
fn atanh(self) -> f32 { self.atanh() }
244294
}
245295

246296
impl Trig for f64 {
@@ -252,6 +302,36 @@ impl Trig for f64 {
252302

253303
#[inline(always)]
254304
fn tan(self) -> f64 { self.tan() }
305+
306+
#[inline(always)]
307+
fn asin(self) -> f64 { self.asin() }
308+
309+
#[inline(always)]
310+
fn acos(self) -> f64 { self.acos() }
311+
312+
#[inline(always)]
313+
fn atan(self) -> f64 { self.atan() }
314+
315+
#[inline(always)]
316+
fn atan2(self, other: f64) -> f64 { self.atan2(other) }
317+
318+
#[inline(always)]
319+
fn sinh(self) -> f64 { self.sinh() }
320+
321+
#[inline(always)]
322+
fn cosh(self) -> f64 { self.cosh() }
323+
324+
#[inline(always)]
325+
fn tanh(self) -> f64 { self.tanh() }
326+
327+
#[inline(always)]
328+
fn asinh(self) -> f64 { self.asinh() }
329+
330+
#[inline(always)]
331+
fn acosh(self) -> f64 { self.acosh() }
332+
333+
#[inline(always)]
334+
fn atanh(self) -> f64 { self.atanh() }
255335
}
256336

257337
/// Casts into another type.

0 commit comments

Comments
 (0)