Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I wanted to derive the formula to give the point of intersection of two lines, each defined by a pair of points. I got the wrong answer and cannot find the error. Which drives me crazy. I don't how how it could be more straightforward. I can get the answer off Wikipedia but I want to know what I did wrong.

I started by constraining the point of intersection $p$ to be colinear with both pairs ($a$ and $b$, $c$ and $d$).

Equating the slopes: $\dfrac{p_y - a_y}{p_x - a_x} = \dfrac{b_y - a_y}{b_x - a_x}$ and $\dfrac{p_y - c_y}{p_x - c_x} = \dfrac{d_y - c_y}{d_x - c_x}$

Solving for $p_y$: $p_y = \dfrac{b_y - a_y}{b_x - a_x}(p_x - a_x) + a_y$ and $p_y = \dfrac{d_y - c_y}{d_x - c_x}(p_x - c_x) + c_y$

Equating the two expressions and solving for $p_x$:

$$\dfrac{b_y - a_y}{b_x - a_x}(p_x - a_x) + a_y = \dfrac{d_y - c_y}{d_x - c_x}(p_x - c_x) + c_y$$ $$p_x\left(\dfrac{b_y - a_y}{b_x - a_x}-\dfrac{d_y - c_y}{d_x - c_x}\right) = a_x\dfrac{b_y - a_y}{b_x - a_x} - a_y - c_x\dfrac{d_y - c_y}{d_x - c_x} + c_y$$ $$p_x = \dfrac{a_x\dfrac{b_y - a_y}{b_x - a_x} - a_y - c_x\dfrac{d_y - c_y}{d_x - c_x} + c_y}{\dfrac{b_y - a_y}{b_x - a_x}-\dfrac{d_y - c_y}{d_x - c_x}}$$

This result for $p_x$ did not give me the expected values for the point of intersection in my graphing software. Wikipedia has:

$$p_x = \dfrac{(a_xb_y - a_yb_x)(c_x - d_x) - (a_x - b_x)(c_xd_y - c_yd_x)}{(a_x - b_x)(c_y - d_y) - (a_y - b_y)(c_x - d_x)}$$

Rearranged to highlight the differences:

$$p_x = \dfrac{\dfrac{c_xd_y - c_yd_x}{d_x - c_x} - \dfrac{a_xb_y - a_yb_x}{b_x - a_x}}{\dfrac{b_y - a_y}{b_x - a_x} - \dfrac{d_y - c_y}{d_x - c_x}}$$

While that expression was derived from determinants, I'd really appreciate knowing where I went wrong the way I was doing it.

share|improve this question
    
Have you tried setting $a$, $b$, $c$, $d$ to some simple values where you can work out the true result on graph paper, and then substituting into your formulas one by one until you find one that's off? –  Henning Makholm Oct 7 '11 at 13:57
    
I said graph paper. For example, try a(0,1), b(4,3), c(3,0), d(1,4). Take each of your intermediate equations, substitute these values and the known answer, and see which equations fail to be true. The first such must be where your error is. –  Henning Makholm Oct 7 '11 at 14:06
    
Oh, I understand. But apparently I was wrong about being wrong. How's that for embarrassing? –  jnm2 Oct 7 '11 at 14:10
add comment

1 Answer 1

up vote 1 down vote accepted

Actually the solutions for $p_x$ you found does agree with that of wikipedia, because

$$ \begin{multline} \left(a_x\dfrac{b_y - a_y}{b_x - a_x} - a_y\right) - \left(c_x\dfrac{d_y - c_y}{d_x - c_x} - c_y\right) =\\ \left( \dfrac{a_x(b_y - a_y)-a_y(b_x-a_x)}{b_x - a_x} \right) - \left( \dfrac{c_x(d_y - c_y)-c_y(d_x-c_x)}{d_x - c_x} \right) = \\ \left( \dfrac{a_x b_y -a_y b_x}{b_x - a_x} \right) - \left( \dfrac{c_x d_y -c_y d_x}{d_x - c_x} \right) \end{multline}$$

Also in Mathematica:

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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