coord_transforms icon indicating copy to clipboard operation
coord_transforms copied to clipboard

Generic over f64/f32?

Open bjadamson opened this issue 4 years ago • 2 comments
trafficstars

Hi there,

Thanks for making this crate! Would you be open to supporting f32's as well as just f64?

ie: https://docs.rs/coord_transforms/1.3.0/coord_transforms/d2/fn.cartesian2polar.html is hardcoded for f64.

Right now I'm doing a bunch of unnecessary casts because my engine uses f32's atm. I'm still learning rust, but if your knowledgeable about a good method for doing so (maybe something like rust's Into trait?) I would be happy to put together a PR, if your open to merging/discussing it.

Thanks!

bjadamson avatar Mar 08 '21 10:03 bjadamson

Sorry, been working a lot so I don't usually have time to respond quickly to things anymore.

I thought of doing a more generic approach when I first started this a few years ago, but ended up not. There is the potential for using the num_traits crate, and using the Float trait to provide per function generic definitions for f32 and f64 since they both implement Float.

Thoughts?

DaveKram avatar Mar 10 '21 03:03 DaveKram

That seems very reasonable. I'll see when I can find some time to work on this. Thanks for letting me know your interested in merging changes.

bjadamson avatar Mar 10 '21 19:03 bjadamson