Point-to-line distance in 2D: dot vs cross – which one am I supposed to use?

I’m trying to get the perpendicular distance from a point to a line using vectors in 2D, and I keep mixing up when to use dot vs cross.

Set-up: The line goes through A with direction d, and the point is P. I’ve seen a formula that says the distance is |(P−A) × d| / |d|. I’ve also seen it done via projection with the dot product. I think I’m conflating them.

Simple numbers: A = (1, 2), d = (3, 1), P = (4, 0). Then AP = P−A = (3, −2).
– Projection length of AP onto d: (AP · d)/|d| = (3*3 + (−2)*1)/√(3^2 + 1^2) = 7/√10.
– “Cross” in 2D: AP × d = 3*1 − (−2)*3 = 9. Candidate distance: |AP × d|/|d| = 9/√10.

I’m unsure about a few things:
– Which of these two quantities is actually the perpendicular distance, and why? I suspect the cross-based one, but I don’t see the geometric step that justifies dividing by |d| (and I’m second-guessing whether it should be |d| or |d|^2).
– In 2D, is using x1*y2 − y1*x2 the right “cross product” here? Why does that correspond to an area in this context?
– Is there a clean way to connect the dot-product approach (using a unit direction vector and the Pythagorean relation) to the same distance without expanding everything by hand?

If someone can point out the mistake in my reasoning and confirm the correct formula using the numbers above, that would help me reconcile these two approaches.

3 Responses

  1. Love this question-dot and cross are like two different “lenses” on the same picture: shadow vs area! For the perpendicular distance from P to the line through A with direction d, the clean formula is distance = |(P−A) × d| / |d|. Geometrically, |u × v| = |u||v| sinθ is the area of the parallelogram spanned by u and v, so dividing by the base length |d| leaves the height-exactly the perpendicular distance; if you scale d, the area scales the same way, which is why you divide by |d| (not |d|^2). In 2D, the “cross” is the scalar x1y2 − y1x2; it’s the signed area measure (people often say “area of the triangle,” which is off by a factor of 2, but the height logic still guides you). Plugging your numbers: AP = (3, −2), d = (3, 1), so AP × d = 3·1 − (−2)·3 = 9 and |d| = √10, giving distance = 9/√10. The dot-product view is the shadow lens: the projection length along the line is (AP · d)/|d| = 7/√10 (that’s along d, not perpendicular), and you can connect the two by Pythagoras: |AP|^2 = (parallel)^2 + (perp)^2, so perp = sqrt(|AP|^2 − ((AP · d)^2/|d|^2)) = sqrt(13 − 49/10) = 9/√10 again. Analogy time: think of d as the base of a tilted book and AP as a bookmark sticking out-the cross product gives the “area of the page,” and dividing by the base gives the page’s height, i.e., how far the bookmark sticks out perpendicularly.

  2. Think of the two tools like this: the dot product measures how far you slide along the line’s direction, while the “2D cross” (the little determinant x1*y2 − y1*x2) measures how much area your vector sweeps sideways-so the perpendicular distance is the side‑ways bit. Geometrically, if AP = P−A and d is the direction, then |AP×d| = |AP||d| sinθ is the area of the parallelogram spanned by AP and d, so the height (i.e., the perpendicular distance from P to the line through A in direction d) is area divided by the base |d|, giving distance = |AP×d|/|d|; that’s why we divide by |d| (not |d|^2). The dot route gets the same thing cleanly by using a unit normal: take n = (-d_y, d_x)/|d| (a 90° rotation of d), then distance = |AP · n|, since dotting with a unit normal plucks out exactly the perpendicular component (the projection length (AP·d)/|d| is the along‑the‑line part-it’s always nonnegative, which is why it’s called a length… tiny fib: it can be signed, but we usually take its magnitude when we say “length”). With your numbers, A=(1,2), d=(3,1), P=(4,0), we have AP=(3,−2), |d|=√10. Cross way: AP×d = 3·1 − (−2)·3 = 9, so distance = |9|/√10 = 9/√10. Dot‑with‑normal way: n = (−1,3)/√10, so AP·n = (3,−2)·(−1,3)/√10 = (−3−6)/√10 = −9/√10, and the absolute value again gives 9/√10. If you prefer Pythagoras: |AP|=√13 and the along‑line projection is (AP·d)/|d|=7/√10, so the perpendicular is √(13 − 49/10)=9/√10-ta‑da, everything harmonizes. Nice bonus: the sign of AP×d tells you which side of the line P lives on. For a friendly refresher on projections and why these formulas click, see Khan Academy’s dot‑product and projection explainer: https://www.khanacademy.org/math/linear-algebra/vectors-and-spaces/dot-prod/a/defining-the-dot-product.

  3. Use the cross one: distance = |(P−A)×d|/|d|, because |(P−A)×d| is the parallelogram area = |P−A||d|sinθ, so dividing by |d| gives the perpendicular height |P−A|sinθ (in 2D, × means x1y2−y1x2; equivalently distance = |(P−A)·n| with n = perp(d)/|d|). Example: A=(1,2), d=(3,1), P=(4,0) ⇒ AP=(3,−2), AP×d=3·1−(−2)·3=9 and |d|=√10, so distance=9/√10; dot method with n=(−1,3)/√10 gives |AP·n|=|-9|/√10=9/√10.

Leave a Reply

Your email address will not be published. Required fields are marked *

Join Our Community

Ready to make maths more enjoyable, accessible, and fun? Join a friendly community where you can explore puzzles, ask questions, track your progress, and learn at your own pace.

By becoming a member, you unlock:

  • Access to all community puzzles
  • The Forum for asking and answering questions
  • Your personal dashboard with points & achievements
  • A supportive space built for every level of learner
  • New features and updates as the Hub grows