`DirX::new` should be more explicit about normalization and have a code example
How can Bevy's documentation be improved?
The documentation for the new constructors of direction types doesn't explicitly state that the given vector gets automatically normalized by the method.
For example, Dir2:
/// Create a direction from a finite, nonzero [`Vec2`].
///
/// Returns [`Err(InvalidDirectionError)`](InvalidDirectionError) if the length
/// of the given vector is zero (or very close to zero), infinite, or `NaN`.
Arguably, the normalization is implied because it "creates a direction", which based on the type's definition should be normalized. Still, I have seen several users do something like this:
Dir2::new(target.normalize()).unwrap()
resulting in a double normalization.
We should make the comment more explicit about the normalization, and also add a code example in the doc comment to show how the type is intended to be used. This code example could also showcase some error cases, like a zero vector.
Next method in the doc is Dir2::new_unchecked which states that it is for already normalized vectors. This is very idiomatic way to have method with guaranties for any data and method_unchecked for already proved data for double check optimization