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 $\mid\textbf{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
$\mid\textbf{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?
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 = c\vec 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}}$$