Skip to content

Instantly share code, notes, and snippets.

@rokujyouhitoma
Created September 14, 2015 14:50
Show Gist options
  • Save rokujyouhitoma/ba651db30be86a35b14b to your computer and use it in GitHub Desktop.
Save rokujyouhitoma/ba651db30be86a35b14b to your computer and use it in GitHub Desktop.
# http://imagingsolution.blog107.fc2.com/blog-entry-137.html
def x(p1, p2, p3, p4):
s1 = (p4.x - p2.x) * (p1.y - p2.y) - (p4.y - p2.y) * (p1.x - p2.x)
s2 = (p4.x - p2.x) * (p2.y - p3.y) - (p4.y - p2.y) * (p3.x - p3.x)
(x,y) = p1.x + (p3.x - p1.x) * s1 / (s1 + s2), p1.y + (p3.y - p1.y) * s1 / (s1 + s2)
return (x,y)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment