Last active
September 4, 2017 01:15
-
-
Save bhavishyagopesh/a27bed76dd3be852546ba5b6f9f5d1a9 to your computer and use it in GitHub Desktop.
To verify `Pappus Theorem`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """In mathematics, Pappus's hexagon theorem (attributed to Pappus of Alexandria) states that given one set of | |
| collinear points A, B, C, and another set of collinear points a, b, c, then the intersection points X, Y, Z of | |
| line pairs Ab and aB, Ac and aC, Bc and bC are collinear, lying on the Pappus line. | |
| """ | |
| from sympy import * | |
| from sympy.geometry import * | |
| l1 = Line(Point(0, 0), Point(5, 6)) | |
| l2 = Line(Point(0, 0), Point(2, -2)) | |
| def subs_point(l, val): | |
| """Take an arbitrary point and make it a fixed point.""" | |
| t = Symbol('t', real=True) | |
| ap = l.arbitrary_point() | |
| return Point(ap.x.subs(t, val), ap.y.subs(t, val)) | |
| p11 = subs_point(l1, 5) | |
| p12 = subs_point(l1, 6) | |
| p13 = subs_point(l1, 11) | |
| p21 = subs_point(l2, -1) | |
| p22 = subs_point(l2, 2) | |
| p23 = subs_point(l2, 13) | |
| ll1 = Line(p11, p22) | |
| ll2 = Line(p11, p23) | |
| ll3 = Line(p12, p21) | |
| ll4 = Line(p12, p23) | |
| ll5 = Line(p13, p21) | |
| ll6 = Line(p13, p22) | |
| pp1 = intersection(ll1, ll3)[0] | |
| pp2 = intersection(ll2, ll5)[0] | |
| pp3 = intersection(ll4, ll6)[0] | |
| print (Point.is_collinear(pp1, pp2, pp3)) # Prints true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment