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.
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 notInto<f32>
to partially calculate the vector norm, as the currentmagnitude
function is strictly limited tof32
results.