New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ang_vel.to_radians()
is a footgun
#13
Comments
I guess one workaround would be to just add documentation comments that specify that Something like this: /// The angular velocity of a body, expressed in radians.
///
/// **Note**: Because the component's value is already in radians, calling the derived method `to_radians` will probably not produce the expected result.
#[cfg(feature = "2d")]
#[derive(Reflect, Clone, Copy, Component, Debug, Default, Deref, DerefMut, PartialEq, From)]
#[reflect(Component)]
pub struct AngVel(pub f32); Like you said, we could also just remove |
Yeah, the reason it's particularly tempting is that we have e.g. this fails: let rot = Rot::from_radians(PI);
assert_relative_eq!(PI, rot.to_radians()); I think removing the deref impl would probably be best here... but let's maybe wait and see a bit. |
For now I'll just remove the If someone has a better approach, feel free to reopen this issue. |
Because
AngVel
implementsDeref<f32>
, we will getstd::f32::to_radians
, which converts from degrees to radians, butAngVel
is already in radians...Not sure how we'd fix this besides removing the derive for
Deref
fromAngVel
and the other components... It's a trade-off and we'd lose some nice ergonomics. Just putting this here in case anyone else has a good idea about how to go about it.The text was updated successfully, but these errors were encountered: