kvark / mint

Math Interoperability Types
MIT License
256 stars 20 forks source link

Example? #55

Closed krooq closed 4 years ago

krooq commented 4 years ago

At risk of sounding like an idiot, how does one actually use mint in their code?

Can someone whip up like a tiny example for me, maybe whack it in the README?

kvark commented 4 years ago

11 lists the libraries we know that have integrated mint support. For example, you can look at the code in three-rs examples https://github.com/three-rs/three/pull/24:

dir_light.transform_mut().look_at([150.0, 350.0, 350.0].into(),
                                      [0.0, 0.0, 0.0].into(),
                                      None);

Does that help?

krooq commented 4 years ago

I understand the "to mint" direction well. But how do I go about translating back to do some math? I feel like it's gonna get real ugly real quick if I'm calling into() every time I want to add 2 vectors together? Maybe this is only the case for operators? Maybe I'm missing something obvious?

kvark commented 4 years ago

Well, the point is that the ugly is an implementation detail. The PR I linked contains both "to mint" and "from mint" parts. For example of the latter, see look_at implementation.

krooq commented 4 years ago

Yeah ok, doesn't seem too bad really. I think my initial usage attempt was just bit under engineered. I'm used to things "just working" with Rust but here there is a little bit of extra work to do, which honestly I should have expected. Rust has spoiled me with it's type inference!

Thanks for explaining kvark! I'm thoroughly enjoying your contributions to the Rust ecosystem 😄

kvark commented 4 years ago

Alright, do you think there needs to be done about this? I.e. are readme changes needed?

krooq commented 4 years ago

More examples are always welcoming for newbies :) But I think those that are intending on integrating mint probably immediately know the implications of mint. The concept is pretty straight forward, I think I'm just fairly new to Rust so these things aren't so obvious to me.

kvark commented 4 years ago

Yeah, I believe that's the case.