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

Add magnitude_sq function to support non-f32 #118

Merged
merged 1 commit into from
Sep 5, 2024

Conversation

sunsided
Copy link
Contributor

Extracted from #114, this provides the magnitude_sq function that calculates the squared magnitude of a vector (e.g. as the squared Euclidean distance between two points). This function is useful in general to speed up relative comparisons where taking the square root isn't strictly necessary, e.g. sorting by distance, as the square root function is monotonic and therefore doesn't change the outcome.

This also allows for C: Component types that re not Into<f32> to partially calculate the vector norm, as the current
magnitude function is strictly limited to f32 results.

@sunsided sunsided force-pushed the feature/magnitude-sq-standalone branch from 82a02a7 to 123f5ef Compare July 31, 2024 08:54
@tarcieri tarcieri merged commit f6fa6a5 into tarcieri:main Sep 5, 2024
11 checks passed
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

Successfully merging this pull request may close these issues.

2 participants