   Want a vector of known length newbie Q
  HiI'm trying to get a vector of specific Length L in a given direction.Just on Paper this is what I've come up with.Is this correct?Lets say I know I want a vector os Length L.H = Hypoth O = Oppostite A= Adjacent.I am looking for O A as they are the coordinates of the vectorTheta is angle of vector.So the H of my triangle is of length L.Therefore the ratio (0/A) squared is LInverse Tan(sqrt(L)) = Theta.L Sin(Theta) = OppL Cos(Theta) = AdjAre there any optimizations or am I even in the right ball park?Joninty   
  If it needs to be a specific length in a given direction, just normalize the direction vector and multiply the direction vector by the desired length.  No need to go through all that trig.Edit1: Though, if yor direction is in the form of just an angle, then what you do there would equate to finding a normalized direction vector and multiplying it by the desired lengthEdit2: Quote:Therefore the ratio (0/A) squared is LInverse Tan(sqrt(L)) = Theta.That doesn't work.  L^2 = O^2 + A^2, and O/A = tan(theta), so theta = arctan(O/A).  Nowhere can you make a direct ratio relationship between O and A.  To see what I mean, draw a circle of any size.  According to what you're saying, you can draw a line from the origin to the edge of the circle, then use that line as the hypotenuse of a right triangle.  What you're saying there is that the ratio of lengths of the other two sides is constant with respect to the length of the hypotenuse.  You'll see that that's clearly not the case if you draw a few different triangles that way.I should really read through to the end before I post... then I don't have to make so many edits...-Auron   ;  If you are saying you want to find the coordinates of a vector of length L at an angle theta, then yes those equations will work:Opp = L*Sin(Theta);Adj = L*Cos(Theta);Once you have one of the lengths, you could solve for the other with:Adj = sqrt(L^2 - Opp^2);I'm not sure which way is more optimal though.;  Since you said that you already know the coordinates of the direction (as opposed to the angle), then no trigonometry is required.  All you need to do is normalize the vector (make it so that it has a length of one unit, a "unit vector"), and then multiply it by the length that you desire (one multiplied by a number is that number).  In two dimensional Cartesian space, you get the length of the vector by taking the square root of the sum of each coordinate squared, according to the Phythagorean theorem.Length = SquareRoot(x2 + y2)Then to get the new (x', y') vector of the appropriate length, divide each coordinate by the original length (to get a length of one), and multiply by the new length:x' = (x / Length) * DesiredLengthy' = (y / Length) * DesiredLengthx' and y' will now be your new vector of the appropriate length.[Edited by - Agony on June 21, 2006 11:27:12 AM];  Besides the things the above replies already mentioned, there seems me a bug in your conclusions:Quote:Original post by jonintyTheta is angle of vector.So the H of my triangle is of length L.Therefore the ratio (0/A) squared is LInverse Tan(sqrt(L)) = Theta.L Sin(Theta) = OppL Cos(Theta) = AdjDue to Pythagoras,H2 = A2 + O2so thatL := |H| = sqrt( A2 + O2 ) [you have instead a ratio there!]Moreover,sin(theta) := O/Hcos(theta) := A/Htan(theta) = sin(theta) / cos(theta) = O/Aso thattheta = InvTan( O/A )Notice that H could be enlarged without changing theta, but in your equation  the theta would change with L!   