Giter Club home page Giter Club logo

Comments (3)

Jondolf avatar Jondolf commented on May 10, 2024

I guess one workaround would be to just add documentation comments that specify that AngVel (and other angular components) use radians, and hope that users understand not to use to_radians. If we want to be more explicit, we can specifically mention that to_radians probably won't do what you expect, since it's already in radians.

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 Deref, at least from the components that use radians, but I wouldn't remove it from every component because of ergonomics. Removing it from just a few components would reduce consistency though...

from bevy_xpbd.

johanhelsing avatar johanhelsing commented on May 10, 2024

Yeah, the reason it's particularly tempting is that we have Rot::from_radians, so it's particularly tempting to try to call through your IDE's auto-completion, and I don't think warnings in the reference would help much then.

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.

from bevy_xpbd.

Jondolf avatar Jondolf commented on May 10, 2024

For now I'll just remove the Deref impl from the 2D AngularVelocity (see #46). I agree that it's probably the best way to go about this.

If someone has a better approach, feel free to reopen this issue.

from bevy_xpbd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.