• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 722
  • Last Modified:

Vector scaling to a specific value

Suppose I have a 3D normal vector (x,y,z), and I am given a brightness value V. How can I find the scaling factor such that x^2 + y^2 + z^2 = V^2?
  • 3
1 Solution
If you know x, y, and z (which it sounds like you do) then "V" is the magnitude of the vector:

   V = sqrt[x^2 + y^2 + z^2]

But you've already said that you have a "3D normal vector," which means the magnitude is 1 (and so is V then), so this question doesn't really make sense. Can you please clarify?
If you have a unit vector, then:

 x^2 + y^2 + z^2 = 1


 v^2(x^2 + y^2 + z^2) = V^2


 V^2 * x^2 + V^2 * y^2 + V^2 * z^2 = V^2

So, given V you're components are:


sph2105Author Commented:
Sorry. Let me clarify.

x,y and z are indeed known,
V is some value that I have precalculated from some other function.

I need to scale x,y and z such that its magnitude (i.e. sqrt(x^2 + y^2 + z^2)) is equal to V.

Another way to look at is, I need x^2 + y^2 + z^2 = V^2.

The magnitude of vector (x,y,z) is not necessarily equal to V. I need to scale x,y and z it so that it IS always equal to V.

Sorry about that

let's call the magnitude m.

m = sqrt[x^2 + y^2 + z^2]


You want: Vx/m, Vy/m, Vz/m

Turn the vector into a unit vector then scale by V.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now