How to convert a vector to a unit vector if it's magnitude is smaller than one?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












In my javascript project, I need to convert a vector to a unit vector. I know that I can divide its x and y components by its magnitude. But what if the vector's magnitude is smaller than one? How to make it a unit vector then ?







share|cite|improve this question


















  • 1




    "it's" (abbreviation of "it is") should be $to$ "its"
    – Jean Marie
    Aug 12 '16 at 19:57














up vote
-1
down vote

favorite












In my javascript project, I need to convert a vector to a unit vector. I know that I can divide its x and y components by its magnitude. But what if the vector's magnitude is smaller than one? How to make it a unit vector then ?







share|cite|improve this question


















  • 1




    "it's" (abbreviation of "it is") should be $to$ "its"
    – Jean Marie
    Aug 12 '16 at 19:57












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











In my javascript project, I need to convert a vector to a unit vector. I know that I can divide its x and y components by its magnitude. But what if the vector's magnitude is smaller than one? How to make it a unit vector then ?







share|cite|improve this question














In my javascript project, I need to convert a vector to a unit vector. I know that I can divide its x and y components by its magnitude. But what if the vector's magnitude is smaller than one? How to make it a unit vector then ?









share|cite|improve this question













share|cite|improve this question




share|cite|improve this question








edited Aug 27 at 16:48









Bungo

13.2k22044




13.2k22044










asked Aug 12 '16 at 19:10









arandomguy

14617




14617







  • 1




    "it's" (abbreviation of "it is") should be $to$ "its"
    – Jean Marie
    Aug 12 '16 at 19:57












  • 1




    "it's" (abbreviation of "it is") should be $to$ "its"
    – Jean Marie
    Aug 12 '16 at 19:57







1




1




"it's" (abbreviation of "it is") should be $to$ "its"
– Jean Marie
Aug 12 '16 at 19:57




"it's" (abbreviation of "it is") should be $to$ "its"
– Jean Marie
Aug 12 '16 at 19:57










1 Answer
1






active

oldest

votes

















up vote
4
down vote



accepted










The same way. Divide by its magnitude. Remember that when you divide by a number that’s less than one, you’re increasing the total value.






share|cite|improve this answer




















  • Oh I understand. Thanks.
    – arandomguy
    Aug 12 '16 at 19:14






  • 2




    Minor quibble: you need to make sure the magnitude is nonzero.
    – Barry Cipra
    Aug 12 '16 at 19:15










  • @BarryCipra yes.
    – arandomguy
    Aug 12 '16 at 19:16






  • 1




    @BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
    – amd
    Aug 12 '16 at 19:21











Your Answer




StackExchange.ifUsing("editor", function ()
return StackExchange.using("mathjaxEditing", function ()
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
);
);
, "mathjax-editing");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "69"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1890478%2fhow-to-convert-a-vector-to-a-unit-vector-if-its-magnitude-is-smaller-than-one%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
4
down vote



accepted










The same way. Divide by its magnitude. Remember that when you divide by a number that’s less than one, you’re increasing the total value.






share|cite|improve this answer




















  • Oh I understand. Thanks.
    – arandomguy
    Aug 12 '16 at 19:14






  • 2




    Minor quibble: you need to make sure the magnitude is nonzero.
    – Barry Cipra
    Aug 12 '16 at 19:15










  • @BarryCipra yes.
    – arandomguy
    Aug 12 '16 at 19:16






  • 1




    @BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
    – amd
    Aug 12 '16 at 19:21















up vote
4
down vote



accepted










The same way. Divide by its magnitude. Remember that when you divide by a number that’s less than one, you’re increasing the total value.






share|cite|improve this answer




















  • Oh I understand. Thanks.
    – arandomguy
    Aug 12 '16 at 19:14






  • 2




    Minor quibble: you need to make sure the magnitude is nonzero.
    – Barry Cipra
    Aug 12 '16 at 19:15










  • @BarryCipra yes.
    – arandomguy
    Aug 12 '16 at 19:16






  • 1




    @BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
    – amd
    Aug 12 '16 at 19:21













up vote
4
down vote



accepted







up vote
4
down vote



accepted






The same way. Divide by its magnitude. Remember that when you divide by a number that’s less than one, you’re increasing the total value.






share|cite|improve this answer












The same way. Divide by its magnitude. Remember that when you divide by a number that’s less than one, you’re increasing the total value.







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Aug 12 '16 at 19:12









amd

26.6k21046




26.6k21046











  • Oh I understand. Thanks.
    – arandomguy
    Aug 12 '16 at 19:14






  • 2




    Minor quibble: you need to make sure the magnitude is nonzero.
    – Barry Cipra
    Aug 12 '16 at 19:15










  • @BarryCipra yes.
    – arandomguy
    Aug 12 '16 at 19:16






  • 1




    @BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
    – amd
    Aug 12 '16 at 19:21

















  • Oh I understand. Thanks.
    – arandomguy
    Aug 12 '16 at 19:14






  • 2




    Minor quibble: you need to make sure the magnitude is nonzero.
    – Barry Cipra
    Aug 12 '16 at 19:15










  • @BarryCipra yes.
    – arandomguy
    Aug 12 '16 at 19:16






  • 1




    @BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
    – amd
    Aug 12 '16 at 19:21
















Oh I understand. Thanks.
– arandomguy
Aug 12 '16 at 19:14




Oh I understand. Thanks.
– arandomguy
Aug 12 '16 at 19:14




2




2




Minor quibble: you need to make sure the magnitude is nonzero.
– Barry Cipra
Aug 12 '16 at 19:15




Minor quibble: you need to make sure the magnitude is nonzero.
– Barry Cipra
Aug 12 '16 at 19:15












@BarryCipra yes.
– arandomguy
Aug 12 '16 at 19:16




@BarryCipra yes.
– arandomguy
Aug 12 '16 at 19:16




1




1




@BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
– amd
Aug 12 '16 at 19:21





@BarryCipra True, but one always has to check for that. That wasn’t the gist of the question.
– amd
Aug 12 '16 at 19:21


















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f1890478%2fhow-to-convert-a-vector-to-a-unit-vector-if-its-magnitude-is-smaller-than-one%23new-answer', 'question_page');

);

Post as a guest













































































這個網誌中的熱門文章

How to combine Bézier curves to a surface?

Mutual Information Always Non-negative

Why am i infinitely getting the same tweet with the Twitter Search API?