Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Denormalize vector

How can I denormalize a vector that has been normalized to get the original values prior to normalizing?

For example:

vec = [-0.5, -1.0, 0.0]
vec_length = sqrt(vec.x^2 + vec.y^2 + vec.z^2)
vec_normalized = [vec.x/vec_length, vec.y/vec_length, vec.z/vec_length]

yields:

vec_length = 1.11803
vec_normalized = [-0.447214,-0.894427,0]

How can I get the original vector [-0.5, -1.0, 0.0] from the normalized vector [-0.447214,-0.894427,0]?

Thanks!

like image 517
user3417614 Avatar asked Dec 26 '22 02:12

user3417614


1 Answers

You can't.
There are infinite number of vectors whose normalized form is [-0.447214, -0.894427, 0].

If you want a "nicer" form, you can try up-scaling to an arbitrary number, random example:

I want x to be -3:

scale = -3 / vec_normalized.x;
vec2 = [vec_normalized.x * scale, vec_normalized.y * scale, vec_normalized.z * scale];

result:

scale = 6.70819787
vec2 = [-3, -6, 0]

But be careful not to choose a component which is 0, because that would yield scale = infinity.

like image 119
TWiStErRob Avatar answered Dec 28 '22 10:12

TWiStErRob