Is your feature request related to a problem? Please describe.
A vector can be scaled, but its magnitude cannot be set explicitly.
Describe the solution you'd like
Either a separate command (vec set-magnitude), or a subcommand (vec magnitude set, for instance), which updates the components of the vector.
Describe alternatives you've considered
The effect can be emulated by first normalizing, then scaling the vector with the factor of the desired magnitude.
Like other requests, though, this is not quite as readable as having a dedicated operation.
Also, this would give opportunities for optimization:
Calculate vector magnitude --> O(n)
Divide new magnitude by the original one, figuring out the ratio --> O(1) !
Multiply all values by the ratio --> O(n)
instead of...
Calculate vector magnitude --> O(n)
Divide all values by that original magnitude --> O(n)
Is your feature request related to a problem? Please describe. A vector can be scaled, but its magnitude cannot be set explicitly.
Describe the solution you'd like Either a separate command (
vec set-magnitude
), or a subcommand (vec magnitude set
, for instance), which updates the components of the vector.Describe alternatives you've considered The effect can be emulated by first normalizing, then scaling the vector with the factor of the desired magnitude. Like other requests, though, this is not quite as readable as having a dedicated operation.
Also, this would give opportunities for optimization:
--> O(n)
--> O(1)
!--> O(n)
instead of...
--> O(n)
--> O(n)
--> O(n)