2323from mapclientplugins .segmentationstep .maths .vectorops import add , cross , div , dot , normalize , sub , mult
2424from mapclientplugins .segmentationstep .misc import checkRange
2525
26+
2627def boundCoordinatesToCuboid (pt1 , pt2 , cuboid_dimensions ):
2728 '''
2829 Takes two points and a cuboids dimensions, with
@@ -63,6 +64,7 @@ def boundCoordinatesToCuboid(pt1, pt2, cuboid_dimensions):
6364
6465 return bounded_pt
6566
67+
6668def pointOutsideCuboid (pt , cuboid_dimensions ):
6769 '''
6870 Determine if the given point is outside the cuboid and
@@ -86,6 +88,7 @@ def pointOutsideCuboid(pt, cuboid_dimensions):
8688
8789 return outside
8890
91+
8992def calculateLinePlaneIntersection (pt1 , pt2 , point_on_plane , plane_normal ):
9093 line_direction = sub (pt2 , pt1 )
9194 d = dot (sub (point_on_plane , pt1 ), plane_normal ) / dot (line_direction , plane_normal )
@@ -95,6 +98,7 @@ def calculateLinePlaneIntersection(pt1, pt2, point_on_plane, plane_normal):
9598
9699 return None
97100
101+
98102def calculateCentroid (point_on_plane , plane_normal , cuboid_dimensions ):
99103 '''
100104 Takes a description of a plane as a point on the plane
@@ -143,6 +147,7 @@ def calculateCentroid(point_on_plane, plane_normal, cuboid_dimensions):
143147 plane_centre = ca .compute ()
144148 return plane_centre
145149
150+
146151class CentroidAlgorithm (object ):
147152
148153 def __init__ (self , xi ):
@@ -227,12 +232,14 @@ def _calculateCxCy(vertices, area):
227232 cy /= 6 * area
228233 return cx , cy
229234
235+
230236def _calculatePolygonArea (vertices ):
231237 area = 0.0
232238 for i in range (len (vertices ) - 1 ):
233239 area += (vertices [i ][0 ] * vertices [i + 1 ][1 ] - vertices [i + 1 ][0 ] * vertices [i ][1 ])
234240 return 0.5 * area
235241
242+
236243def _calculateHeading (direction ):
237244 '''
238245 Convert a vector based direction into a heading
0 commit comments