Skip to content
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

Change normalize function #46

Closed
sidred opened this issue Feb 10, 2016 · 1 comment
Closed

Change normalize function #46

sidred opened this issue Feb 10, 2016 · 1 comment

Comments

@sidred
Copy link
Contributor

sidred commented Feb 10, 2016

fn normalize_angle_division(mut deg: f32) -> f32 {
    let c360 = 360.0_f32;
    deg - ((deg / c360).floor() * c360)

}

Faster than using mod and as fast as while. No slowdown for large numbers. Putting it here so I don't forget.

@Ogeon
Copy link
Owner

Ogeon commented Feb 10, 2016

👍

@homu homu closed this as completed in #47 Feb 10, 2016
homu added a commit that referenced this issue Feb 10, 2016
Change normalize to use floor and ceil formula

Change normalize function to use floor and ceil based formula without loops. This is faster than using modulo operator and as fast as the existing while loop based solution. No slowdown for large numbers unlike while loop based solution.

Closes #46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants