1
$\begingroup$

I need an algorithm that returns the point of intersection between two lines. The algorithm is capable of determining the relative position then I'm sure the lines will intersect.

My question is: I want to avoid linear systems in my program so I found this resolution:

$$ \lambda\in{R} $$ $$ r: (x, y, z) + \lambda\vec{v}_1 $$ $$ s: (x_2, y_2, z_2) + \mu\vec{v}_2 $$ $$ \lambda = \mu \, \therefore \lambda(\vec{v}_1 \times \vec{v}_2) = ((x, y, z) - (x_2, y_2, z_2)) \times \vec{v}_2 $$

So it's just I find the value of lambda and replace the equations of lines. But I can't isolate the lambda because the equation will be a division between vectors and the resolution says "we can solve for 'a' by taking the magnitude of each side and dividing"
What does that mean? I don't have native English and it was very confusing I thank if someone can explain

$\endgroup$
1
$\begingroup$

You want to solve for $\lambda$ in the expression: $$\lambda(\vec{v}_1 \times \vec{v}_2) = ((x, y, z) - (x_2, y_2, z_2)) \times \vec{v}_2$$ To do that you can "take the maginitude" of the vector on the left and right hand side of the equation. Here magnitude of a 3d vector $w$ is $$|w| = \sqrt{w_1^2 + w_2^2 + w_3^2}$$ So $$|\lambda(\vec{v}_1 \times \vec{v}_2)| = |((x, y, z) - (x_2, y_2, z_2)) \times \vec{v}_2|$$ You can distribute out the $\lambda$ to find: $$|\lambda||(\vec{v}_1 \times \vec{v}_2)| = |((x, y, z) - (x_2, y_2, z_2)) \times \vec{v}_2|$$ and $$|\lambda| = \frac{|(\vec{v}_1 \times \vec{v}_2)|}{|((x, y, z) - (x_2, y_2, z_2)) \times \vec{v}_2|}$$

Note: I would suggest instead of using the above technique just looking at the ratio of an two coordinates of the vector on the LHS and RHS. i.e. when you have an equation: $$\lambda u = v$$ where $u, v$ are vectors and $\lambda$ is a constant, then $$\lambda = \frac{v_i}{u_i}$$ for any component that isn't $0$. This way you will obtain the sign of $\lambda$. The expression (written in coordinates) will probably be simpler as well.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.