view Resources/Computations/IntersectSegmentAndVerticalLine.py @ 1345:0d6a01ffa1dd broker

Clean version of the hack commited in the previous commit : the DicomStructureSetLoader now properly increments its revision during progressive loading. The "force update" method in the VolumeSceneLayerSource isn't needed anymore.
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 06 Apr 2020 09:17:40 +0200
parents 35c2b85836ce
children
line wrap: on
line source

#!/usr/bin/env python

from sympy import *

# Intersection between the 2D line segment (prevX,prevY)-(curX,curY) and the
# vertical line "x = x0" using homogeneous coordinates

prevX, prevY, curX, curY, x0 = symbols('prevX prevY curX curY x0')

p1 = Matrix([prevX, prevY, 1])
p2 = Matrix([curX, curY, 1])
l1 = p1.cross(p2)

h1 = Matrix([x0, 0, 1])
h2 = Matrix([x0, 1, 1])
l2 = h1.cross(h2)

a = l1.cross(l2)

pprint(a / a[2])