Normalize vector to euclidean unit length
I know I can compute a vector of unit length in a given direction using something like
v = some_vector_computation() v = v/v.norm() some_other_computation(v)
On the other hand, the most intuitive way to write this in a single line won't work:
This is because of the way
normalize is defined, which is well documented and has been discussed in this question.
So I wonder, is there some other way to write the above in a single line? I'm not interested in solutions which call
some_vector_computation twice, or have to name the vector, or use some lambda function, or similar hacks. I very much have a method in mind, but anything with similar complexibility and readability would be fine.
I know I could probably add my own method to the vector class at runtime, but modifying sage classes in this way doesn't exactly feel right. And I fear that using a non-standard method might make my code much harder to read, as others would expect being able to reproduce it, but won't be able to if they missed my custom method.
If there is no such method, do you agree that there should be, and that I should file a feature request on the Sage Trac?