File tree 4 files changed +21
-0
lines changed
4 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -414,6 +414,12 @@ impl Trigonometric for f32 {
414
414
415
415
#[ inline( always) ]
416
416
fn atan2 ( & self , other : f32 ) -> f32 { atan2 ( * self , other) }
417
+
418
+ /// Simultaneously computes the sine and cosine of the number
419
+ #[ inline( always) ]
420
+ fn sin_cos ( & self ) -> ( f32 , f32 ) {
421
+ ( self . sin ( ) , self . cos ( ) )
422
+ }
417
423
}
418
424
419
425
impl Exponential for f32 {
Original file line number Diff line number Diff line change @@ -426,6 +426,12 @@ impl Trigonometric for f64 {
426
426
427
427
#[ inline( always) ]
428
428
fn atan2 ( & self , other : f64 ) -> f64 { atan2 ( * self , other) }
429
+
430
+ /// Simultaneously computes the sine and cosine of the number
431
+ #[ inline( always) ]
432
+ fn sin_cos ( & self ) -> ( f64 , f64 ) {
433
+ ( self . sin ( ) , self . cos ( ) )
434
+ }
429
435
}
430
436
431
437
impl Exponential for f64 {
Original file line number Diff line number Diff line change @@ -530,6 +530,14 @@ impl Trigonometric for float {
530
530
fn atan2 ( & self , other : float ) -> float {
531
531
( * self as f64 ) . atan2 ( other as f64 ) as float
532
532
}
533
+
534
+ /// Simultaneously computes the sine and cosine of the number
535
+ #[ inline( always) ]
536
+ fn sin_cos ( & self ) -> ( float , float ) {
537
+ match ( * self as f64 ) . sin_cos ( ) {
538
+ ( s, c) => ( s as float , c as float )
539
+ }
540
+ }
533
541
}
534
542
535
543
impl Exponential for float {
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub trait Trigonometric {
118
118
fn acos ( & self ) -> Self ;
119
119
fn atan ( & self ) -> Self ;
120
120
fn atan2 ( & self , other : Self ) -> Self ;
121
+ fn sin_cos ( & self ) -> ( Self , Self ) ;
121
122
}
122
123
123
124
pub trait Exponential {
You can’t perform that action at this time.
0 commit comments