1
$\begingroup$

I'm trying to learn Computational Geometry and this formula isn't obvious to me.

Hint: cross is related to the cross product of two vectors.

# Returns intersection of infinite lines ab and pq (or undefined)
point intersect(point a, point b, point p, point q):
    d1 = cross(p - a, b - a)
    d2 = cross(q - a, b - a)
    return (d1 * q - d2 * p) / (d1 - d2)
$\endgroup$
4
  • 1
    $\begingroup$ It's not clear what you're asking. Do you know what the cross function does? Do you understand what the intersect function does? $\endgroup$
    – Pål GD
    Jun 16, 2020 at 12:51
  • $\begingroup$ Thanks for response .... I mean i need the proof of correctness of this method ... I try some values and it works but how ? I always solve it by solving two algebraic equations of the two lines . $\endgroup$ Jun 16, 2020 at 15:23
  • $\begingroup$ I'd suggest looking at this: stackoverflow.com/questions/563198/… $\endgroup$
    – user
    Jun 16, 2020 at 21:24
  • $\begingroup$ helpful, thanks . $\endgroup$ Jun 17, 2020 at 11:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.