annotate Resources/Computations/IntersectSegmentAndHorizontalLine.py @ 973:38409549db43 toa2019082903

Log with addresses + added fingerprint mechanism to avoid calling zombie objects where: - a message is sent with a receiver - the receiver dies - another receiver with the SAME address is created - the message reply is executed --> execution on the wrong object! (since their "identity" is their address. The fix is to identify them with an UUID stored at creation time)
author Benjamin Golinvaux <bgo@osimis.io>
date Thu, 29 Aug 2019 18:07:55 +0200
parents 35c2b85836ce
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
132
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 from sympy import *
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Intersection between the 2D line segment (prevX,prevY)-(curX,curY) and the
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # horizontal line "y = y0" using homogeneous coordinates
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 prevX, prevY, curX, curY, y0 = symbols('prevX prevY curX curY y0')
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 p1 = Matrix([prevX, prevY, 1])
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 p2 = Matrix([curX, curY, 1])
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 l1 = p1.cross(p2)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 h1 = Matrix([0, y0, 1])
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 h2 = Matrix([1, y0, 1])
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 l2 = h1.cross(h2)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 a = l1.cross(l2)
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 #pprint(cse(a/a[2], symbols = symbols('a b')))
35c2b85836ce fix rtstruct projections
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 pprint(a / a[2])