From world space to object's space. Scaling. I am developing a ray tracer and I need to compute intersections between many surfaces and rays. A classical method to make the computation time lower and the code simpler is to define some constants in surfaces equations (for example a sphere is centered at the origin and has a radius of 1) but apply some transformations (scale, rotate and translate) to get the correct result. Being a newbie in maths, I started to experiment before coding and found some strange things I can't explain.
First, let's talk about translation. I reduced the problem to a 2D world to be clearer.

Here $\vec{v}$ is the direction vector of the thrown ray $\Delta$. THis ray should intersect with the circle centered at B. To go from the first circle to the second circle we made a center translation using $\vec{u}$, so to move the ray into the object space we just have to apply a translation of $-\vec{u} = \vec{u'}$ on one of its point. It then gives the correct result.
It seems that there's no problem for translation. Now I want to do the same operation with scaling.

Here I scaled my circle isotropically by 3. And then I do not know how to transform the ray into object space.
I tried to use matrices, but I probably messed up a bit so I didn't find a working solution. Any ideas ?
 A: To answer your question ... to handle scaling, you first translate the circle so that its center is at the origin, and then you scale it to make its radius equal to 1. Apply those same transforms to the point on the ray. You don't need to do anything to the vector of the ray.
But I think all this transformation stuff is the wrong approach personally. It's not hard to figure out the intersection of an arbitrary ray and an arbitrary sphere. And I think that computation will be faster than translating back and forth.
Suppose the ray has equation $\mathbf{r}(t) = \mathbf{a} + t\mathbf{v}$, and the sphere has center $\mathbf{c}$ and radius $r$. Then, at intersection points, we have
$$
\|\mathbf{r}(t) - \mathbf{c}\|^2 = r^2
$$
which gives
$$
(\mathbf{a} + t\mathbf{v} - \mathbf{c} ) \cdot 
(\mathbf{a} + t\mathbf{v} - \mathbf{c} ) = r^2
$$
Let $\mathbf{u} = \mathbf{a}  - \mathbf{c}$. Then we get
$$
(\mathbf{u} + t\mathbf{v}) \cdot 
(\mathbf{u} + t\mathbf{v} ) = r^2
$$
so
$$
(\mathbf{u}.\mathbf{u}) + 2(\mathbf{u}.\mathbf{v})t + (\mathbf{v}.\mathbf{v})t^2 = r^2
$$
You can solve this quadratic to get the "$t$" values of the two points on the ray where it intersects the sphere. Much faster than transformations, and conceptually easier, too (in my opinion).
