How to scale a 2D vector and keep direction I want to take any vector in R2 and scale its length to 1 while keeping the original direction (ratio of x component to y). As an example of my goal, let's say I have the vector (1,1), it would become $(\frac{\sqrt{2}}{2}, \frac{\sqrt{2}}{2})$ . The vector (0,5) would become (0,1). You can see how the answer is not so apparent if the original vector is something like (0.98, 2.6). I hope for a function that can solve this for me but the best I've been able to do is convert the vector into an angle and then calculate dimensions using trig and the unit circle. How would you go about this?
Bonus - find a function that can scale a vector to any inputted size while keeping the direction. 
As a final note, I do not have access to R, Matlab, etc. 

To normalize any vector you simply need to divide each component by its magnitude. In your first example, you changed from $(1,1)$ to $(\frac{\sqrt2}2,\frac{\sqrt2}2)$, or in your second example, from $(0,5)$ to $(0,1)$ but how did you get there? You may not have realized it but essentially you just divided each component by the magnitude.
Given a vector $(a,b)$, the magnitude is:
$$
\sqrt{a^{2} + b^{2}}
$$
Simply divide each component of your vector by this magnitude and your vector will be of length one, a unit vector.
