File tree Expand file tree Collapse file tree 4 files changed +21
-0
lines changed
Expand file tree Collapse file tree 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 {
414414
415415 #[ inline( always) ]
416416 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+ }
417423}
418424
419425impl Exponential for f32 {
Original file line number Diff line number Diff line change @@ -426,6 +426,12 @@ impl Trigonometric for f64 {
426426
427427 #[ inline( always) ]
428428 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+ }
429435}
430436
431437impl Exponential for f64 {
Original file line number Diff line number Diff line change @@ -530,6 +530,14 @@ impl Trigonometric for float {
530530 fn atan2 ( & self , other : float ) -> float {
531531 ( * self as f64 ) . atan2 ( other as f64 ) as float
532532 }
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+ }
533541}
534542
535543impl Exponential for float {
Original file line number Diff line number Diff line change @@ -118,6 +118,7 @@ pub trait Trigonometric {
118118 fn acos ( & self ) -> Self ;
119119 fn atan ( & self ) -> Self ;
120120 fn atan2 ( & self , other : Self ) -> Self ;
121+ fn sin_cos ( & self ) -> ( Self , Self ) ;
121122}
122123
123124pub trait Exponential {
You can’t perform that action at this time.
0 commit comments