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

Replaces inconsistent implementations of the square root of 2 #10070

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

BeeLover66
Copy link
Contributor

About The Pull Request

in the code, the define SQRT_TWO was used at one place to approximate the square root of 2. At another place, the value was written directly. this PR replaces these inconsistent implementations with the inbuilt proc sqrt(2), which constant folds to 1.4142135.

Although this is not a port, this PR does the same thing as tgstation/tgstation#72913, which is listed in the "Things to Port" project: https://github.com/BeeStation/BeeStation-Hornet/projects/2#card-88347615

Why It's Good For The Game

using sqrt(2) is more readable and concise than a magic number or an obsolete define, and the computational cost is not increased.

Testing Photographs and Procedure

Screenshots&Videos
sqrt2proof.mov

According to approximate timing, the diagonal movement took about 1.4 times longer than the straight movement, which matches the expected value of sqrt(2).

Changelog

🆑
code: Square root of 2 is now only written as sqrt(2) in the code
/:cl:

@EvilDragonfiend EvilDragonfiend added this pull request to the merge queue Oct 26, 2023
Merged via the queue into BeeStation:master with commit 7b7ca9d Oct 26, 2023
@BeeLover66 BeeLover66 deleted the sqrt2 branch October 27, 2023 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants