Math in Unity : Intersections (Part II)

Now that we have seen the 2D perpendicular Vector, we can move on with our calculations.
If you remember, we stuck with this formula

vt = c + us

For now, the only way to solve the problem with t and s is to remove one of the two from the equation.
We start with t and remove the s.
And since we decided to start with t, we should completely remove us.

Now, since we have seen how to make a Vector return a value of zero thanks to the perp with this formula

We can just remove the second part and get this formula

From this formula, the way to calculate t is

If instead we wanted to solve the problem by removing the t and calculating the s, the formula would be this.
We start again from this

vt = c + us

This time we have this

Now we can replace the first part like this

To replace the zero, we need to take the last part and make it “negative”

But as we saw in the previous article, the “negative” part can be replaced with the other perpendicular Vector

This leads us to the conclusion that s =

Thanks to these two formulas

we can calculate the time t along the Vector u and the time s along the Vector v

Now enough with the theory, in the next article we will see all this in practice!