# how to get the vec according to cos value.

This topic is 4974 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

given cos of a angle of a vector and a x axis, how to get that vector? if I use dot product to get the cos value,and will have 2 angle related to that cos value. so how to get one of them? simply:a cos have two corresponding a angle.I mean cos(270) = cos(90)

##### Share on other sites
You can't get either 1 of 2 vectors from the dot product without knowing one of them.

Even if you know one of the vectors, there is an infinite number of secondary vectors.

ace

##### Share on other sites
Ace is right, of course. You might be able to limit the problem if you consider only unit vectors, but you'll still have two solutions for your problem. Then, you'll have to choose which one you'll discard (maybe you'll want only the one which gaves you a positive angle).

If your known vector is [X, Y, Z] (length=1), and the one you want to find is [x y z] then the final answer is the solution of these equations:

x*x + y*y + z*z = 1
x*X + y*Y + z*Z = cos(a)

You'll see that you have 2 equations, and 3 unknowns.

Good luck ;)

##### Share on other sites
Quote:
 Original post by derek7given cos of a angle of a vector and a x axis, how to get that vector?

Like you said, there are two possible vectors. If we are talking about unit vectors, then the solutions are [cos a, sqrt(1-cos2 a)] and [cos a, -sqrt(1-cos2 a)]. If you don't care which one, then just pick one. If you do care which one, then you need another constraint in order to pick the right one.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 15
• 14
• 46
• 22
• 27
• ### Forum Statistics

• Total Topics
634053
• Total Posts
3015265
×