# Math Help - Generating new vectors from an original vector

1. ## Generating new vectors from an original vector

Hi math gurus,

Not sure if my question is in the right section of this forum, but here it goes. I have a normalized 3D vector (a normal from a 3D model), and now I'd like to generate 4 vectors around this original one, under an angle of 45 degrees. Something like this:
Code:
< looking on top of the normal vector (notated as o) >
< Rotation does not matter, as long as vector 1/2/3/4 form a cross around o >
2
|
1---o---3
|
4
< Looking at the side of the normal vector >
< You can't see it here, but there should be 45 degrees between the vector1/2/3/4 and vector o>
o
1       |     2
\     |    /
\    |   /
\45 |  /
\ | /
The normal vector could point any direction, and is normalized (the values are between -1..+1). The rotation of the 4 vectors around the normal (as in the "top" view) does not matter, as long as it forms a cross. So, the question is, how to calculate these 4 vectors? Or how to calculate at least 1 vector, and then rotate it around vector o?

Ow, and to be more specific, the calculations need to be done in a shader program for computer graphics.

Excuse me for the "ASCII art" (hope its not screwed up)
Greetings,
Rick

2. Originally Posted by Spek
Hi math gurus,

Not sure if my question is in the right section of this forum, but here it goes. I have a normalized 3D vector (a normal from a 3D model), and now I'd like to generate 4 vectors around this original one, under an angle of 45 degrees. Something like this:
Code:
< looking on top of the normal vector (notated as o) >
< Rotation does not matter, as long as vector 1/2/3/4 form a cross around o >
2
|
1---o---3
|
4
< Looking at the side of the normal vector >
< You can't see it here, but there should be 45 degrees between the vector1/2/3/4 and vector o>
o
1       |     2
\     |    /
\    |   /
\45 |  /
\ | /
The normal vector could point any direction, and is normalized (the values are between -1..+1). The rotation of the 4 vectors around the normal (as in the "top" view) does not matter, as long as it forms a cross. So, the question is, how to calculate these 4 vectors? Or how to calculate at least 1 vector, and then rotate it around vector o?

Ow, and to be more specific, the calculations need to be done in a shader program for computer graphics.

Excuse me for the "ASCII art" (hope its not screwed up)
Greetings,
Rick
I don't know what your background in vectors is ....... are you familiar with the dot (scalar) product? If so:

Call the normalised vector n, say. Then you want to construct vectors 1, 2, 3 and 4 to satisfy the following equations:

1.n = 0
2.n = 0
3.n = 0
4.n = 0
1.2 = 0
1.4 = 0
2.3 = 0
3.4 = 0

Alternatively, if you're familiar with the cross (vector) product:

Get a vector, 1 say, normal to n from 1.n = 0.

Then 2 = 1 x n, 4 = n x 1, 3 = n x 2 where x is the cross (vector) product.

3. >> I don't know what your background in vectors is ...
Poor But I know the dot product. But I also don't quite the notations you write (sorry!). Maybe I'm not very clear.

In my case I get 1 normalized 3D vector (a normal from a model). That normal has 3 axes, x,y and z. For example, if this vector is pointing upwards (+Y), I would write it as "normal = {0,1,0}". Now I have to generate 4 new vectors (I need to calculate the xyz for v1,v2,v3 and v4). Imagine that you are the normal vector. First you bend over 45 degrees (like Micheal Jackson). Band 45 degrees backward, to the left, and to the right. For each pose, I'd like to know the x/y/z values.

Probably you already explained that in your reply. But I don't know what you mean with "4.n = 0" or "1.2 = 0". Where does 4.n or 1.2 stand for? Probably I'm thinking more in programming terms.

Greetings,
Rick

4. Originally Posted by Spek
>> I don't know what your background in vectors is ...
Poor But I know the dot product. But I also don't quite the notations you write (sorry!). Maybe I'm not very clear.

In my case I get 1 normalized 3D vector (a normal from a model). That normal has 3 axes, x,y and z. For example, if this vector is pointing upwards (+Y), I would write it as "normal = {0,1,0}". Now I have to generate 4 new vectors (I need to calculate the xyz for v1,v2,v3 and v4). Imagine that you are the normal vector. First you bend over 45 degrees (like Micheal Jackson). Band 45 degrees backward, to the left, and to the right. For each pose, I'd like to know the x/y/z values.

Probably you already explained that in your reply. But I don't know what you mean with "4.n = 0" or "1.2 = 0". Where does 4.n or 1.2 stand for? Probably I'm thinking more in programming terms.

Greetings,
Rick
. is the dot product.
1 is vector 1, 2 is vector 2 etc.
If you're familiar witht the dot product you might recall that when the dot product of two vectors is equal to zero, those two vectors are perpendicular to each other.

5. Ah, of course. Excuse me.

But if I understand you right, the vectors make an angle of 90 degrees with the original vector (n). In my case it needs to be 45 degrees, thus
1.n = 0.707, right?

In programming terms, the dot product is calculated like this:
dotproduct = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z

So, if the dotproduct should be 0.707, and "v1" is the given normal... And let's say n is a vector pointing a random (normalized) direction, for example {0, 0.75, 0.82}:
0.707 = n.x * v.x + n.y * v.y + n.z * v.z
0.707 = 0 * v.x + 0.75 * v.y + 0.82 * v.z

Then how to calculate x,y and z of vector v? The rotation of v around n does not matter, as long as their is 90 degrees between the 4 vectors (when you would view on top of vector n).

Thanks for helping!
Rick

6. Originally Posted by Spek
Ah, of course. Excuse me.

But if I understand you right, the vectors make an angle of 90 degrees with the original vector (n). In my case it needs to be 45 degrees, thus
1.n = 0.707, right?

In programming terms, the dot product is calculated like this:
dotproduct = v1.x * v2.x + v1.y * v2.y + v1.z * v2.z

So, if the dotproduct should be 0.707, and "v1" is the given normal... And let's say n is a vector pointing a random (normalized) direction, for example {0, 0.75, 0.82}:
0.707 = n.x * v.x + n.y * v.y + n.z * v.z
0.707 = 0 * v.x + 0.75 * v.y + 0.82 * v.z

Then how to calculate x,y and z of vector v? The rotation of v around n does not matter, as long as their is 90 degrees between the 4 vectors (when you would view on top of vector n).

Thanks for helping!
Rick
OK, I see what you want now - sorry, I misunderstood earlier. It's actually very simple .....

If you 'move' all your vectors (you can always 'move' them back later) so that, looking at an xyz-coordinate system (a 3-d coordinate system) the vector n runs from the origin along the positive z-axis (ie. n = k), then unit vectors 1, 2, 3 and 4 (you can re-length all vectors later) are:

1 = i/sqrt{2} + k/sqrt{2}

2 = -i/sqrt{2} + k/sqrt{2}

3 = j/sqrt{2} + k/sqrt{2}

4 = -j/sqrt{2} + k/sqrt{2}

i, j, k are the usual unit vectors in the x, y and z directions.

7. Sorry for the late reply, I had a busy weekend. Ok, let's see if I understand it a little bit. Told you that my math was poor

First I move my N vector towards the positive Z axis. Do you mean I'll have to rotate it? For example, what to do if N is {0,1,0} (= pointing towards +Y axis)? I guess I'm wrong about this. Notice that the vector N is just a direction in 3D-space, it's origin is always at {0,0,0} and the length is 1.

The 'moved' vector is called K, and then I could perform:
i = (1,0,0)
j = (0,1,0)
k = (0,0,1)
1.x = i.x / sqrt{2} + k.x / sqrt{2}
1.y = i.y / sqrt{2} + k.y / sqrt{2}
1.z = i.z / sqrt{2} + k.z / sqrt{2}
...and the same stuff for the other 3 vectors...

Not sure if i,j and k are defined properly. I'm not familiar with the term "unit vector", except that they have a length of 1.

Thanks again,
Rick