Basic Ray casting vector equality problem












0












$begingroup$


I am working through the basic math of the ray casting algorithm detailed here



The problem I am facing is as follows:



There exists this vector $textbf{r}=(r_x,r_y)$ whose magnitude is not equal to 1 aka not a unit vector



There exists this other vector $textbf{s} = (1,s_y)$ that is in the same direction of $textbf{r}$, but has a different magnitude



The author in the link above manages to calculate the magnitude of $textbf{s}$ in terms of $r_x$ and $r_y$ namely $midtextbf{s}mid = sqrt frac{(r_y)^2 + (r_x)^2}{(r_x)^2}$



He claims to have derived it geometrically (no calculation shown)



I see that since both $textbf{r}$ and $textbf{s}$ point in the same direction, I could equate their unit vectors as such
$(frac{1}{sqrt{(s_y)^2 + 1}},_) = (frac{r_x}{sqrt{(r_x)^2 + (r_y)^2)}},_)$ to obtain $s_y = frac{r_y}{r_x}$



and hence



$midtextbf{s}mid = sqrt{1 + s_y^2} = sqrt{1 + frac{r_y^2}{r_x^2}}$



The reason I'm asking on here is because the equality of the unit vectors to obtain the end resulthere seems forced and to a very large degree contrived. Am I wrong here? If so, how and why? Is the method that I have employed non kosher?










share|cite|improve this question









$endgroup$












  • $begingroup$
    Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:13










  • $begingroup$
    @JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
    $endgroup$
    – functor-soup
    Dec 10 '18 at 23:16










  • $begingroup$
    No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:17
















0












$begingroup$


I am working through the basic math of the ray casting algorithm detailed here



The problem I am facing is as follows:



There exists this vector $textbf{r}=(r_x,r_y)$ whose magnitude is not equal to 1 aka not a unit vector



There exists this other vector $textbf{s} = (1,s_y)$ that is in the same direction of $textbf{r}$, but has a different magnitude



The author in the link above manages to calculate the magnitude of $textbf{s}$ in terms of $r_x$ and $r_y$ namely $midtextbf{s}mid = sqrt frac{(r_y)^2 + (r_x)^2}{(r_x)^2}$



He claims to have derived it geometrically (no calculation shown)



I see that since both $textbf{r}$ and $textbf{s}$ point in the same direction, I could equate their unit vectors as such
$(frac{1}{sqrt{(s_y)^2 + 1}},_) = (frac{r_x}{sqrt{(r_x)^2 + (r_y)^2)}},_)$ to obtain $s_y = frac{r_y}{r_x}$



and hence



$midtextbf{s}mid = sqrt{1 + s_y^2} = sqrt{1 + frac{r_y^2}{r_x^2}}$



The reason I'm asking on here is because the equality of the unit vectors to obtain the end resulthere seems forced and to a very large degree contrived. Am I wrong here? If so, how and why? Is the method that I have employed non kosher?










share|cite|improve this question









$endgroup$












  • $begingroup$
    Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:13










  • $begingroup$
    @JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
    $endgroup$
    – functor-soup
    Dec 10 '18 at 23:16










  • $begingroup$
    No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:17














0












0








0





$begingroup$


I am working through the basic math of the ray casting algorithm detailed here



The problem I am facing is as follows:



There exists this vector $textbf{r}=(r_x,r_y)$ whose magnitude is not equal to 1 aka not a unit vector



There exists this other vector $textbf{s} = (1,s_y)$ that is in the same direction of $textbf{r}$, but has a different magnitude



The author in the link above manages to calculate the magnitude of $textbf{s}$ in terms of $r_x$ and $r_y$ namely $midtextbf{s}mid = sqrt frac{(r_y)^2 + (r_x)^2}{(r_x)^2}$



He claims to have derived it geometrically (no calculation shown)



I see that since both $textbf{r}$ and $textbf{s}$ point in the same direction, I could equate their unit vectors as such
$(frac{1}{sqrt{(s_y)^2 + 1}},_) = (frac{r_x}{sqrt{(r_x)^2 + (r_y)^2)}},_)$ to obtain $s_y = frac{r_y}{r_x}$



and hence



$midtextbf{s}mid = sqrt{1 + s_y^2} = sqrt{1 + frac{r_y^2}{r_x^2}}$



The reason I'm asking on here is because the equality of the unit vectors to obtain the end resulthere seems forced and to a very large degree contrived. Am I wrong here? If so, how and why? Is the method that I have employed non kosher?










share|cite|improve this question









$endgroup$




I am working through the basic math of the ray casting algorithm detailed here



The problem I am facing is as follows:



There exists this vector $textbf{r}=(r_x,r_y)$ whose magnitude is not equal to 1 aka not a unit vector



There exists this other vector $textbf{s} = (1,s_y)$ that is in the same direction of $textbf{r}$, but has a different magnitude



The author in the link above manages to calculate the magnitude of $textbf{s}$ in terms of $r_x$ and $r_y$ namely $midtextbf{s}mid = sqrt frac{(r_y)^2 + (r_x)^2}{(r_x)^2}$



He claims to have derived it geometrically (no calculation shown)



I see that since both $textbf{r}$ and $textbf{s}$ point in the same direction, I could equate their unit vectors as such
$(frac{1}{sqrt{(s_y)^2 + 1}},_) = (frac{r_x}{sqrt{(r_x)^2 + (r_y)^2)}},_)$ to obtain $s_y = frac{r_y}{r_x}$



and hence



$midtextbf{s}mid = sqrt{1 + s_y^2} = sqrt{1 + frac{r_y^2}{r_x^2}}$



The reason I'm asking on here is because the equality of the unit vectors to obtain the end resulthere seems forced and to a very large degree contrived. Am I wrong here? If so, how and why? Is the method that I have employed non kosher?







vectors






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Dec 10 '18 at 22:58









functor-soupfunctor-soup

989




989












  • $begingroup$
    Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:13










  • $begingroup$
    @JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
    $endgroup$
    – functor-soup
    Dec 10 '18 at 23:16










  • $begingroup$
    No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:17


















  • $begingroup$
    Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:13










  • $begingroup$
    @JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
    $endgroup$
    – functor-soup
    Dec 10 '18 at 23:16










  • $begingroup$
    No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
    $endgroup$
    – John Douma
    Dec 10 '18 at 23:17
















$begingroup$
Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
$endgroup$
– John Douma
Dec 10 '18 at 23:13




$begingroup$
Your way is correct and you get the same answer. Exploiting the fact that two vectors point in the same direction doesn't seem contrived to me. It seems like a good way to solve the problem.
$endgroup$
– John Douma
Dec 10 '18 at 23:13












$begingroup$
@JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
$endgroup$
– functor-soup
Dec 10 '18 at 23:16




$begingroup$
@JohnDouma I see. What about the part of equating their unit vectors? Do you still think that doesn't feel forced?
$endgroup$
– functor-soup
Dec 10 '18 at 23:16












$begingroup$
No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
$endgroup$
– John Douma
Dec 10 '18 at 23:17




$begingroup$
No. It shows that you understand that two vectors that point in the same direction will have the same unit vectors.
$endgroup$
– John Douma
Dec 10 '18 at 23:17










1 Answer
1






active

oldest

votes


















0












$begingroup$

The direction of two vectors is the same if the ratio of the components is the same: $$frac{r_y}{r_x}=frac{s_y}{1}$$
That's because you can write $vec s = cvec r$ or $(s_x,s_y)=c(r_x,r_y)$.
We can write this as a system of equations for $x$ and $y$ components. Take $c$ from one equation and replace it into the second.



Now all you need to calculate the magnitude is $$|vec s|=sqrt{s_x^2+s_y^2}=sqrt{1+frac{r_y^2}{r_x^2}}$$






share|cite|improve this answer









$endgroup$













    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    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%2f3034611%2fbasic-ray-casting-vector-equality-problem%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0












    $begingroup$

    The direction of two vectors is the same if the ratio of the components is the same: $$frac{r_y}{r_x}=frac{s_y}{1}$$
    That's because you can write $vec s = cvec r$ or $(s_x,s_y)=c(r_x,r_y)$.
    We can write this as a system of equations for $x$ and $y$ components. Take $c$ from one equation and replace it into the second.



    Now all you need to calculate the magnitude is $$|vec s|=sqrt{s_x^2+s_y^2}=sqrt{1+frac{r_y^2}{r_x^2}}$$






    share|cite|improve this answer









    $endgroup$


















      0












      $begingroup$

      The direction of two vectors is the same if the ratio of the components is the same: $$frac{r_y}{r_x}=frac{s_y}{1}$$
      That's because you can write $vec s = cvec r$ or $(s_x,s_y)=c(r_x,r_y)$.
      We can write this as a system of equations for $x$ and $y$ components. Take $c$ from one equation and replace it into the second.



      Now all you need to calculate the magnitude is $$|vec s|=sqrt{s_x^2+s_y^2}=sqrt{1+frac{r_y^2}{r_x^2}}$$






      share|cite|improve this answer









      $endgroup$
















        0












        0








        0





        $begingroup$

        The direction of two vectors is the same if the ratio of the components is the same: $$frac{r_y}{r_x}=frac{s_y}{1}$$
        That's because you can write $vec s = cvec r$ or $(s_x,s_y)=c(r_x,r_y)$.
        We can write this as a system of equations for $x$ and $y$ components. Take $c$ from one equation and replace it into the second.



        Now all you need to calculate the magnitude is $$|vec s|=sqrt{s_x^2+s_y^2}=sqrt{1+frac{r_y^2}{r_x^2}}$$






        share|cite|improve this answer









        $endgroup$



        The direction of two vectors is the same if the ratio of the components is the same: $$frac{r_y}{r_x}=frac{s_y}{1}$$
        That's because you can write $vec s = cvec r$ or $(s_x,s_y)=c(r_x,r_y)$.
        We can write this as a system of equations for $x$ and $y$ components. Take $c$ from one equation and replace it into the second.



        Now all you need to calculate the magnitude is $$|vec s|=sqrt{s_x^2+s_y^2}=sqrt{1+frac{r_y^2}{r_x^2}}$$







        share|cite|improve this answer












        share|cite|improve this answer



        share|cite|improve this answer










        answered Dec 10 '18 at 23:08









        AndreiAndrei

        11.8k21026




        11.8k21026






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Mathematics Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            Use MathJax to format equations. MathJax reference.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3034611%2fbasic-ray-casting-vector-equality-problem%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Tonle Sap (See)

            I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

            Guatemaltekische Davis-Cup-Mannschaft