ac_power/trig/newtypes/
mod.rs

1// Copyright 2023 Enphase Energy, Inc and Universal Interoperability for
2// Grid-Forming Inverters (UNIFI) Consortium.
3//
4//    Licensed under the Apache License, Version 2.0 (the "License");
5//    you may not use this file except in compliance with the License.
6//    You may obtain a copy of the License at
7//
8//        http://www.apache.org/licenses/LICENSE-2.0
9//
10//    Unless required by applicable law or agreed to in writing, software
11//    distributed under the License is distributed on an "AS IS" BASIS,
12//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//    See the License for the specific language governing permissions and
14//    limitations under the License.
15
16mod cos;
17mod sin;
18mod theta;
19
20use core::ops::Mul;
21pub use cos::Cos;
22pub use sin::Sin;
23pub use theta::Theta;
24
25// impliment the trig multiplies for f32, our base primitive
26impl Mul<f32> for Sin {
27    fn mul(self, rhs: f32) -> f32 {
28        f32::from(self) * rhs
29    }
30    type Output = f32;
31}
32
33impl Mul<Sin> for f32 {
34    fn mul(self, rhs: Sin) -> f32 {
35        self * f32::from(rhs)
36    }
37    type Output = f32;
38}
39
40impl Mul<f32> for Cos {
41    fn mul(self, rhs: f32) -> f32 {
42        f32::from(self) * rhs
43    }
44    type Output = f32;
45}
46
47impl Mul<Cos> for f32 {
48    fn mul(self, rhs: Cos) -> f32 {
49        self * f32::from(rhs)
50    }
51    type Output = f32;
52}