!m      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                                   ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z {|}~                                                                     !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~                    !!!!!!!!!!!!!!!!!!!"""####################################$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$%%%%% % % % % %%%%%%%%%%%%&&&&&&& &!&"&#&$&%&&&'&(&)&*&+&,&-&.&/&0&1&2&3&4&5&6&7&8&9&:&;&<&=&>&?&@&A&B&C&D&E'F'G'H'I'J'K'L'M'N'O'P'Q'R'S'T'U'V'W'X'Y'Z'['\']'^'_'`'a'b(c(d(e(f)g)h)i)j)k)l)m)n)o)p)q)r)s)t)u)v)w)x*y*z*{*|*}*~**++++++++++++++++++++++++++++++++++++++++++++++++++,,,,,,,,,,,,,,,,,,,,,----------------....../////000112223333334455555566667777777777777 7 7 7 7 7888888888888888888 8!8"8#8$8%8&8'8(8)8*8+8,8-8.8/808182838485868788898:8;8<8=8>8?8@8A8B8C8D8E8F8G8H8I8J8K8L8M8N8O8P8Q8R8S8T8U8V8W8X8Y8Z8[8\8]8^8_8`8a8b8c8d8e8f8g8h8i8j8k8l8m8n8o9p9q9r9s9t9u9v:w:x:y:z:{:|:}:~:::::::::::::::::::::::::::::::::::::::::::::::;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<<<<<=====>>>>>>>>>>>>>>> > > > > >>>>>>>>>>>>>>>???? ?!?"?#?$@%@&@'@(@)@*@+@,@-@.@/@0@1@2@3@4@5@6@7@8@9@:@;@<@=@>@?@@@A@B@C@D@E@F@G@H@I@J@K@L@M@N@OAPAQARASATAUAVAWAXAYAZA[A\A]A^A_A`AaAbBcBdBeBfCgChCiCjCkClCmCnCoCpCqCrCsCtCuCvCwCxCyCzC{C|C}C~CCDDDDDEEEEEEEEEEEEEEEEEEEEEEEEEEEEFFGGGGGGGGGGGGGGGGGGGGHHHHKNone!%&',-.1234567=>?@AHMPSUVX_gkZ hgeometry,Open on left endpoint; so Closed before open hgeometry.Order on right endpoint; so Open before Closed !")" !)(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.12345678=>?@ADHMPSTUVX_gk`6* hgeometry=A type family for types that have an associated numeric type.+ hgeometryA type family for types that are associated with a dimension. The dimension is the dimension of the geometry they are embedded in. *++*None!%&',-.1234567=>?@AHMPSUVX_gkf, hgeometryAn Interval is essentially a IJ but with possible payload= hgeometryTest if a value lies in an interval. Note that the difference between inInterval and inRange is that the extra value is *not* used in the comparison with inInterval, whereas it is in inRange.*  ,-.23456789:;<=>,-.<;:67892345=>None!%&',-.1234567=>?@AHMPSUVX_gks H hgeometry1Information stored in a node of the Interval TreeQ hgeometry.IntervalTree type, storing intervals of type i[ hgeometry$Anything that looks like an interval^ hgeometry8Given an ordered list of points, create an interval treeO(n)_ hgeometryBuild an interval tree O(n \log n)` hgeometry@Lists the intervals. We don't guarantee anything about the orderrunning time: O(n).a hgeometryFind all intervals that stab x O(\log n + k), where k is the output sizeb hgeometryFind all intervals that stab x O(\log n + k), where k is the output sizec hgeometry@Insert : pre: the interval intersects some midpoint in the tree O(\log n)d hgeometry Delete an interval from the Tree O(\log n)) (under some general position assumption)HIJKLQRSTUV[\]^_`abcdHIJKLVTUQRS][\^_cdba`None%&',-.1234567=>?@AHMPSUVX_gkue hijklmnop oplmnijkh(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gkl hgeometryOInternal nodes store a split point, the range, and an associated data structure hgeometryCLeaf nodes store an atomic range, and an associated data structure. hgeometry.We store atomic ranges a bit more efficiently. hgeometry(Segment tree on a Fixed set of endpoints hgeometryInterval hgeometry%Class for associcated data structures hgeometryNGiven a sorted list of endpoints, without duplicates, construct a segment treeO(n) time hgeometryInterleaves the two lists8interleave (NonEmpty.fromList ["0","1","2"]) ["01","12"]"0" :| ["01","1","12","2"] hgeometryBuild a SegmentTree O(n \log n) hgeometry'Search for all intervals intersecting x O(\log n + k) where k is the output size hgeometryBReturns the associated values of the nodes on the search path to x O(\log n) hgeometry(Gets the range associated with this node hgeometryNPre: the interval should have one of the endpoints on which the tree is built. hgeometry Delete an interval from the tree pre: The segment is in the tree!""KNone%&',-.1234567=>?@AHMPSUVX_gk" None %&',-.1234567=>?@AHMPSUVX_gk hgeometrysDatatype representing d dimensional vectors. Our implementation wraps the implementation provided by fixed-vector. hgeometry.A proxy which can be used for the coordinates. hgeometry-Pattern synonym for two and three dim vectors hgeometryLens into the i th element hgeometry Similar to x above. Except that we don't have a static guarantee that the index is in bounds. Hence, we can only return a Traversal hgeometry!Get the head and tail of a vector  hgeometry.Cross product of two three-dimensional vectors  hgeometryVonversion to a Linear.V2  hgeometryConversion to a Linear.V3  hgeometryConversion from a Linear.V3  hgeometry(Add an element at the back of the vector hgeometry)Get a vector of the first d - 1 elements. hgeometry&Get a prefix of i elements of a vector hgeometry Construct a 2 dimensional vector hgeometry Construct a 3 dimensional vector hgeometry#Destruct a 2 dim vector into a pair           None %&',-.1234567=>?@AHMPSUVX_gk) hgeometryGMapping between the implementation type, and the actual implementation.* hgeometryDatatype representing d dimensional vectors. The default implementation is based n VectorFixed. However, for small vectors we automatically select a more efficient representation.B hgeometry!Get the head and tail of a vector()*+,-./0123456789:;<=>?@ABC765432/01-.*+,)8(9:;<=>?@ABC (C) Frank Staalssee the LICENSE file Frank StaalsNone %&',-.1234567=>?@AHMPSUVX_gkV hgeometryDatatype representing d dimensional vectors. The default implementation is based n VectorFixed. However, for small vectors we automatically select a more efficient representation.d hgeometryLens into the i th elemente hgeometry Similar to dx above. Except that we don't have a static guarantee that the index is in bounds. Hence, we can only return a Traversalf hgeometry(Add an element at the back of the vectorg hgeometry)Get a vector of the first d - 1 elements.i hgeometry&Get a prefix of i elements of a vectorj hgeometry.Cross product of two three-dimensional vectorsUVWXYZ[\]^_`abcdefghijVWX^U_]\[ZY`abcdefghij(C) Frank Staalssee the LICENSE file Frank StaalsNone %&',-.1234567=>?@AHMPSUVX_gk{ hgeometry$Test if v is a scalar multiple of u..Vector2 1 1 `isScalarMultipleOf` Vector2 10 10True-Vector2 1 1 `isScalarMultipleOf` Vector2 10 1False2Vector2 1 1 `isScalarMultipleOf` Vector2 11.1 11.1True2Vector2 1 1 `isScalarMultipleOf` Vector2 11.1 11.2False2Vector2 2 1 `isScalarMultipleOf` Vector2 11.1 11.2False,Vector2 2 1 `isScalarMultipleOf` Vector2 4 2True,Vector2 2 1 `isScalarMultipleOf` Vector2 4 0False| hgeometry8Get the scalar labmda s.t. v = lambda * u (if it exists) hgeometry'Actual implementation of scalarMultiple=UVWXYZ[\]^_`abcdefghij{|}~{|}~ (C) Frank Staalssee the LICENSE file Frank StaalsNone %&',-.1234567=>?@AHMPSUVX_gkP hgeometry1Quadrants of two dimensional points. in CCW order hgeometryPTypes that we can transform by mapping a function on each point in the structure hgeometryA d-dimensional point. hgeometrySimilarly, we can write::{ let& g :: Point 3 r -> r g (Point3 x y z) = z in g myPoint:}3 hgeometryaWe provide pattern synonyms Point2 and Point3 for 2 and 3 dimensional points. i.e. we can write::{ let$ f :: Point 2 r -> r f (Point2 x y) = x in f (point2 1 2):}1 if we want. hgeometry-Point representing the origin in d dimensionsorigin :: Point 4 IntPoint4 [0,0,0,0] hgeometry6Lens to access the vector corresponding to this point.(point3 1 2 3) ^. vectorVector3 [1,2,3] origin & vector .~ Vector3 1 2 3Point3 [1,2,3] hgeometry{Get the coordinate in a given dimension. This operation is unsafe in the sense that no bounds are checked. Consider using  instead.point3 1 2 3 ^. unsafeCoord 22 hgeometry'Get the coordinate in a given dimension point3 1 2 3 ^. coord (C :: C 2)2%point3 1 2 3 & coord (C :: C 1) .~ 10Point3 [10,2,3]'point3 1 2 3 & coord (C :: C 3) %~ (+1)Point3 [1,2,4] hgeometry-Constructs a point from a list of coordinates,pointFromList [1,2,3] :: Maybe (Point 3 Int)Just Point3 [1,2,3] hgeometry,Project a point down into a lower dimension. hgeometryConstruct a 2 dimensional point point2 1 2 Point2 [1,2] hgeometryDestruct a 2 dimensional point_point2 $ point2 1 2(1,2) hgeometryConstruct a 3 dimensional point point3 1 2 3Point3 [1,2,3] hgeometryDestruct a 3 dimensional point_point3 $ point3 1 2 3(1,2,3) hgeometry,Shorthand to access the first coordinate C 1point3 1 2 3 ^. xCoord1point2 1 2 & xCoord .~ 10 Point2 [10,2] hgeometry-Shorthand to access the second coordinate C 2point2 1 2 ^. yCoord2point3 1 2 3 & yCoord %~ (+1)Point3 [1,3,3] hgeometry,Shorthand to access the third coordinate C 3point3 1 2 3 ^. zCoord3point3 1 2 3 & zCoord %~ (+1)Point3 [1,2,4] hgeometryTGiven three points p q and r determine the orientation when going from p to r via q. hgeometryTGiven three points p q and r determine the orientation when going from p to r via q. hgeometrySort the points arround the given point p in counter clockwise order with respect to the rightward horizontal ray starting from p. If two points q and r are colinear with p, the closest one to p is reported first. running time: O(n log n) hgeometryQuadrants around point c; quadrants are closed on their "previous" boundary (i..e the boundary with the previous quadrant in the CCW order), open on next boundary. The origin itself is assigned the topRight quadrant hgeometry$Quadrants with respect to the origin hgeometrygGiven a center point c, and a set of points, partition the points into quadrants around c (based on their x and y coordinates). The quadrants are reported in the order topLeft, topRight, bottomLeft, bottomRight. The points are in the same order as they were in the original input lists. Points with the same x-or y coordinate as p, are "rounded" to above. hgeometryCounter clockwise ordering of the points around c. Points are ordered with respect to the positive x-axis. Points nearer to the center come before points further away. hgeometryClockwise ordering of the points around c. Points are ordered with respect to the positive x-axis. Points nearer to the center come before points further away. hgeometryGiven a center c, a new point p, and a list of points ps, sorted in counter clockwise order around c. Insert p into the cyclic order. The focus of the returned cyclic list is the new point p.running time: O(n) hgeometry-Squared Euclidean distance between two points hgeometry%Euclidean distance between two points))None %&',-.1234567=>?@AHMPSUVX_gkD hgeometryIA class representing types that can be transformed using a transformation hgeometry>A type representing a Transformation for d dimensional objects hgeometry?a matrix of n rows, each of m columns, storing values of type r hgeometry'Compose transformations (right to left) hgeometry"Compute the inverse transformation.inverseOf $ translation (Vector2 (10.0) (5.0))~Transformation {_transformationMatrix = Matrix Vector3 [Vector3 [1.0,0.0,-10.0],Vector3 [0.0,1.0,-5.0],Vector3 [0.0,0.0,1.0]]} hgeometrycCreates a row with zeroes everywhere, except at position i, where the value is the supplied value. hgeometryRow in a translation matrix transRow :: forall n r. ( Arity n, Arity (n- 1), ((n - 1) + 1) ~ n , Num r) => Int -> r -> Vector n r transRow i x = set (V.element (Proxy :: Proxy (n-1))) x $ mkRow i 1 hgeometryzGiven three new unit-length basis vectors (u,v,w) that map to (x,y,z), construct the appropriate rotation that does this.None%&',-.1234567=>?@AHMPSUVX_gk  hgeometry`Result of a query that asks if something is Inside a g, *on* the boundary of the g, or outside. hgeometry#The boundary of a geometric object.None%&',-.1234567=>?@AHMPSUVX_gk  hgeometryA generic (1D) range tree. The rE parameter indicates the type of the coordinates of the points. The qZ represents any associated data values with those points (stored in the leaves), and the v5 types represents the data stored at internal nodes. hgeometryCreates a range tree hgeometry+pre: input is sorted and grouped by x-coord hgeometry$Lists all points in increasing orderrunning time: O(n) hgeometry Range searchrunning time:  O(\log n)  hgeometry>Range search, report the (associated data structures of the)  O(\log n)G nodes that form the disjoint union of the range we are querying with.running time:  O(\log n)  hgeometryThe actual search  hgeometry7Helper function to get the range of a binary leaf tree  hgeometryGet the range of a node hgeometryPerform a counting query          None %&',-.1234567=>?@AHMPSUVX_gk</ hgeometry!Gets all points in the range tree !"#$%&'()*+,-./012,)*+&'(%"#$!-./012 None%&',-.1234567=>?@AHMPSUVX_gk*B hgeometryReturns the discrete frechet distance between two point sequences using the squared Euclidean distance. In other words, returns the square of the (Euclidean) frechet distance.running time: O((nm)), where n and m# are the lengths of the sequences.C hgeometrydReturns the discrete frechet distance between two point sequences using the given distance measure.running time: O((nm)), where n and mc are the lengths of the sequences (and assuming that a distance calculation takes constant time). hgeometrycompute the discrete frechet distance between the subtrajectories up to the given Loc using dpTable for memoization memoization hgeometryLook up a value in the DP Table hgeometryStoer a value in the DP table hgeometryCandidate previous locationsC hgeometrydistance functionBCBC(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk? F hgeometryType used in the closest pair computation. The fields represent the points ordered on increasing y-order and the closest pair (if we know it)H hgeometry+the closest pair and its (squared) distanceI hgeometryJClassical divide and conquer algorithm to compute the closest pair among n points.running time: O(n)J hgeometry\Given an ordering and two nonempty sequences ordered according to that ordering, merge themK hgeometry\Given an ordering and two nonempty sequences ordered according to that ordering, merge themL hgeometry*Function that does the actual merging work hgeometry4ditch the points on the left that are too low anyway hgeometryEthe squared vertical distance (in case r lies above l) or 0 otherwise hgeometrytry and find a new closest pair with r. If we get to points that are too far above r we stop (since none of those points will be closer to r anyway) hgeometryRGiven some function that decides when to keep things while maintaining some state. hgeometry7returns the minimum element according to some function. hgeometry.Get the distance of a (candidate) closest pairL hgeometry!current closest pair and its dist hgeometrypts on the left hgeometrypts on the rightFGHIJKLIHFGLJK(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkNP hgeometrybA priority search tree storing points in (mathbb{R}^2) that have an additional payload of type p. hgeometryqInternal nodes store the max x-value from the left subtree and the point that has globally the max-y coordinate.S hgeometryFCreates a Priority Search Tree for 3-sided range queries of the form _l,x_r] \times [y,\infty).the base tree will be static.)pre: all points have unique x-coordinatesrunning time:  O(n\log n) hgeometry-Inserts a point into the priority search treerunning time:  O(\log n)T hgeometryGiven a three sided range  [x_l,x_r],y! report all points in the range _l,x_r] \times [y,\infty)2. The points are reported in decreasing order of y -coordinate.running time:  O(\log n + k), where k" is the number of reported points. hgeometry%Implementation fo the query function.PQRSTPQRST(C) Frank Staalssee the LICENSE file Frank StaalsNone#%&',-.12345679=>?@AHMPSUVX_gk~[ hgeometryJA line is given by an anchor point and a vector indicating the direction.` hgeometryResult of a side testd hgeometry`Types for which we can compute a supporting line, i.e. a line that contains the thing of type t.h hgeometry*A line may be constructed from two points.k hgeometryGiven a line l with anchor point p and vector v, get the line perpendicular to l that also goes through p. The resulting line m is oriented such that v points into the left halfplane of m.4perpendicularTo $ Line (Point2 3 4) (Vector2 (-1) 2)%Line (Point2 [3,4]) (Vector2 [-2,-1])l hgeometry.Test if a vector is perpendicular to the line.m hgeometrymTest if two lines are identical, meaning; if they have exactly the same anchor point and directional vector.n hgeometry#Test if the two lines are parallel.TlineThrough origin (point2 1 0) `isParallelTo` lineThrough (point2 1 1) (point2 2 1)TrueTlineThrough origin (point2 1 0) `isParallelTo` lineThrough (point2 1 1) (point2 2 2)Falseo hgeometryTest if point p lies on line l/origin `onLine` lineThrough origin (point2 1 0)True5point2 10 10 `onLine` lineThrough origin (point2 2 2)True4point2 10 5 `onLine` lineThrough origin (point2 2 2)Falsep hgeometry8Specific 2d version of testing if apoint lies on a line.q hgeometryGet the point at the given position along line, where 0 corresponds to the anchorPoint of the line, and 1 to the point anchorPoint .+^ directionVectorr hgeometryGiven point p and a line (Line q v), Get the scalar lambda s.t. p = q + lambda v. If p does not lie on the line this returns a Nothing.s hgeometryuGiven point p *on* a line (Line q v), Get the scalar lambda s.t. p = q + lambda v. (So this is an unsafe version of r)*pre: the input point p lies on the line l.t hgeometry'Squared distance from point p to line lu hgeometrybThe squared distance between the point p and the line l, and the point m realizing this distance.v hgeometry-Create a line from the linear function ax + bw hgeometrygget values a,b s.t. the input line is described by y = ax + b. returns Nothing if the line is verticalx hgeometryGiven a point q and a line l, compute to which side of l q lies. For vertical lines the left side of the line is interpeted as below.8point2 10 10 `onSide` (lineThrough origin $ point2 10 5)Above;point2 10 10 `onSide` (lineThrough origin $ point2 (-10) 5)Above%point2 5 5 `onSide` (verticalLine 10)Below;point2 5 5 `onSide` (lineThrough origin $ point2 (-3) (-3))Ony hgeometry6Test if the query point q lies (strictly) above line lz hgeometry#Get the bisector between two points{ hgeometryVCompares the lines on slope. Vertical lines are considered larger than anything else.B(Line origin (Vector2 5 1)) `cmpSlope` (Line origin (Vector2 3 3))LTE(Line origin (Vector2 5 1)) `cmpSlope` (Line origin (Vector2 (-3) 3))GTB(Line origin (Vector2 5 1)) `cmpSlope` (Line origin (Vector2 0 1))LT hgeometryKThe intersection of two lines is either: NoIntersection, a point or a line. [\^]`bacdefghijklmnopqrstuvwxyz{ [\^]gfhijklmnopqrstudevw`bacxyz{(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gkF  hgeometryrPart of a line. The interval is ranged based on the vector of the line l, and s.t.t zero is the anchorPoint of l. hgeometry3Annotate the subRange with the actual ending points hgeometryDforget the extra information stored at the endpoints of the subline. hgeometry?Transform into an subline with a potentially unbounded interval hgeometry?Try to make a potentially unbounded subline into a bounded one. hgeometrytgiven point p, and a Subline l r such that p lies on line l, test if it lies on the subline, i.e. in the interval r hgeometrytgiven point p, and a Subline l r such that p lies on line l, test if it lies on the subline, i.e. in the interval r hgeometrytgiven point p, and a Subline l r such that p lies on line l, test if it lies on the subline, i.e. in the interval r hgeometrytgiven point p, and a Subline l r such that p lies on line l, test if it lies on the subline, i.e. in the interval r hgeometry*Get the endpoints of an unbounded interval(C) Frank Staalssee the LICENSE file Frank StaalsNone#%&',-./1234567=>?@AHMPSUVX_gk hgeometryCoordinate wize minimum hgeometryCoordinate wize maximum hgeometrybGiven the point with the lowest coordinates and the point with highest coordinates, create a box. hgeometrygrows the box by x on all sides hgeometry)Build a d dimensional Box given d ranges. hgeometryNGiven a center point and a vector specifying the box width's, construct a box. hgeometryCenter of the box hgeometryCheck if a point lies a boxQorigin `inBox` (boundingBoxList' [point3 1 2 3, point3 10 20 30] :: Box 3 () Int)FalseZorigin `inBox` (boundingBoxList' [point3 (-1) (-2) (-3), point3 10 20 30] :: Box 3 () Int)True hgeometryGet a vector with the extent of the box in each dimension. Note that the resulting vector is 0 indexed whereas one would normally count dimensions starting at zero.Iextent (boundingBoxList' [point3 1 2 3, point3 10 20 30] :: Box 3 () Int)`Vector3 [Range (Closed 1) (Closed 10),Range (Closed 2) (Closed 20),Range (Closed 3) (Closed 30)] hgeometryGet the size of the box (in all dimensions). Note that the resulting vector is 0 indexed whereas one would normally count dimensions starting at zero.>size (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)Vector3 [1,2,3] hgeometryXGiven a dimension, get the width of the box in that dimension. Dimensions are 1 indexed.LwidthIn (C :: C 1) (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)1LwidthIn (C :: C 3) (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)3 hgeometrySame as 6 but with a runtime int instead of a static dimension.DwidthIn' 1 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)Just 1DwidthIn' 3 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)Just 3EwidthIn' 10 (boundingBoxList' [origin, point3 1 2 3] :: Box 3 () Int)Nothing hgeometryGet the corners of a rectangle, the order is: (TopLeft, TopRight, BottomRight, BottomLeft). The extra values in the Top points are taken from the Top point, the extra values in the Bottom points are taken from the Bottom point hgeometryOUnsafe version of boundingBoxList, that does not check if the list is non-empty""(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gk@  hgeometryLine segments. LineSegments have a start and end point, both of which may contain additional data of type p. We can think of a Line-Segment being defined as\data LineSegment d p r = LineSegment (EndPoint (Point d r :+ p)) (EndPoint (Point d r :+ p)) hgeometryHGets the start and end point, but forgetting if they are open or closed. hgeometry6Pattern that essentially models the line segment as a:\data LineSegment d p r = LineSegment (EndPoint (Point d r :+ p)) (EndPoint (Point d r :+ p)) hgeometryTraversal to access the endpoints. Note that this traversal allows you to change more or less everything, even the dimension and the numeric type used, but it preservers if the segment is open or closed. hgeometry,Directly convert a line into a line segment. hgeometry'Test if a point lies on a line segment.N(point2 1 0) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))TrueN(point2 1 1) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))FalseN(point2 5 0) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))FalseQ(point2 (-1) 0) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))FalseN(point2 1 1) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 3 3 :+ ()))TrueVNote that the segments are assumed to be closed. So the end points lie on the segment.N(point2 2 0) `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))TrueHorigin `onSegment` (ClosedLineSegment (origin :+ ()) (point2 2 0 :+ ()))True,This function works for arbitrary dimensons.R(point3 1 1 1) `onSegment` (ClosedLineSegment (origin :+ ()) (point3 3 3 3 :+ ()))TrueR(point3 1 2 1) `onSegment` (ClosedLineSegment (origin :+ ()) (point3 3 3 3 :+ ()))False hgeometryNThe left and right end point (or left below right if they have equal x-coords) hgeometryLength of the line segment hgeometryNSquared distance from the point to the Segment s. The same remark as for the  applies here. hgeometryESquared distance from the point to the Segment s, and the point on s realizing it. Note that if the segment is *open*, the closest point returned may be one of the (open) end points, even though technically the end point does not lie on the segment. (The true closest point then lies arbitrarily close to the end point). hgeometry,flips the start and end point of the segment5 ,-.23456789:;<=>5 ,-.23456789:;<=>None!%&',-.1234567=>?@AHMPSUVX_gk hgeometry]reports true if there is at least one segment for which this intersection point is interior.O(1)        None%&',-.1234567=>?@AHMPSUVX_gk: hgeometry#Compute all intersections (naively)O(n^2) hgeometryHTest if the two segments intersect, and if so add the segment to the map hgeometry"Add s and s' to the map with key p hgeometry(figure out which map to add the point to(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk  hgeometry1The actual event consists of a point and its type$ hgeometryType of segment( hgeometryCompute all intersectionsO((n+k)\log n), where k is the number of intersections.) hgeometry`Computes all intersection points p s.t. p lies in the interior of at least one of the segments.O((n+k)\log n), where k is the number of intersections.* hgeometry2Computes the event points for a given line segment+ hgeometry/Group the segments with the intersection points, hgeometry\Group the startpoints such that segments with the same start point correspond to one event.- hgeometry4An ordering that is decreasing on y, increasing on x. hgeometry4Get the segments that start at the given event point/ hgeometryYCompare based on the x-coordinate of the intersection with the horizontal line through y0 hgeometryGiven a y coord and a line segment that intersects the horizontal line through y, compute the x-coordinate of this intersection point.Lnote that we will pretend that the line segment is closed, even if it is not1 hgeometry!Run the sweep handling all events3 hgeometryHandle an event point4 hgeometryjsplit the status structure, extracting the segments that contain p. the result is (before,contains,after)5 hgeometry`Given a point and the linesegements that contain it. Create a piece of status structure for it.6 hgeometry#Get the right endpoint of a segment7 hgeometryTest if a segment ends at p8 hgeometryFind all events !#"$'&%()*+,-./012345678()*+,$'&% !#"-./012345678(C) Frank Staalssee the LICENSE file Frank StaalsNone#%&',-.12345679=>?@AHMPSUVX_gk @ hgeometryOriented from *left to right*B hgeometry-The right side, oriented from *bottom* to topC hgeometryThe sides of the rectangle, in order (Top, Right, Bottom, Left). The sides themselves are also oriented in clockwise order. If, you want them in the same order as the functions ?, @, A, and B, use D instead.D hgeometryYThe sides of the rectangle. The order of the segments is (Top, Right, Bottom, Left). Note that the segments themselves, are oriented as described by the functions topSide, bottomSide, leftSide, rightSide (basically: from left to right, and from bottom to top). If you want the segments oriented along the boundary of the rectangle, use the C function instead.(?@ABCD?A@BCDNone"%&',-.1234567=>?@AHMPSUVX_gkF hgeometry*A Poly line in R^d has at least 2 verticesJ hgeometry0pre: The input list contains at least two pointsK hgeometry`pre: The input list contains at least two points. All extra vields are initialized with mempty.L hgeometry'We consider the line-segment as closed.M hgeometry@Convert to a closed line segment by taking the first two points.N hgeometry\Stricter version of asLineSegment that fails if the Polyline contains more than two points. FGHIJKLMN FGHIJKLMN(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@ADHMPSUVX_gk\ hgeometry*Lines are transformable, via line segments [\]^`cabdefghijklmnopqrstuvwxyz{None!%&',-.1234567=>?@AHMPSUVX_gki hgeometryMThe two bounding lines of the slab, first the lower one, then the higher one:l hgeometry0Smart consturctor for creating a horizontal slabm hgeometry.Smart consturctor for creating a vertical slab ]^_`bahjiklm `ba]^_klmhjiNone#%&',-.12345679=>?@AHMPSUVX_gk#y hgeometryHyperplanes embedded in a d dimensional space.~ hgeometrymTypes for which we can compute a supporting hyperplane, i.e. a hyperplane that contains the thing of type t. hgeometry%Convert between lines and hyperplanes yz|{~ yz|{~ None#%&',-.12345679=>?@AHMPSUVX_gk( hgeometryd-dimensional Half-Lines hgeometry#Test if a point lies on a half-line hgeometryTransform a LineSegment into a half-line, by forgetting the second endpoint. Note that this also forgets about if the starting point was open or closed.  !(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gk2 hgeometryA Halfspace in d dimensions. hgeometry6Get the halfplane left of a line (i.e. "above") a lineleftOf $ horizontalLine 4]HalfSpace {_boundingPlane = HyperPlane {_inPlane = Point2 [0,4], _normalVec = Vector2 [0,1]}} hgeometry7Get the halfplane right of a line (i.e. "below") a linerightOf $ horizontalLine 4^HalfSpace {_boundingPlane = HyperPlane {_inPlane = Point2 [0,4], _normalVec = Vector2 [0,-1]}} hgeometry#Test if a point lies in a halfspace  "None%&',-.1234567=>?@AHMPSUVX_gk6 hgeometry1Maps a line point (px,py) to a line (y=px*x - py) hgeometryZReturns Nothing if the input line is vertical Maps a line l: y = ax + b to a point (a,-b) hgeometry#Pre: the input line is not vertical#None %&',-.1234567=>?@AHMPSUVX_gk; hgeometry1Expects the input to be a set, i.e. no duplicatesrunning time:  O(n \log n) hgeometryNub by sorting first hgeometrySearches in a KDTreerunning time: O(n^{(d-1)/d} + k) hgeometryrunning time: O(n)$(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gkP  hgeometryA d-dimensional ball. hgeometry%Spheres, i.e. the boundary of a ball. hgeometry&A lens to get/set the radius of a Ball hgeometry?Given two points on the diameter of the ball, construct a ball. hgeometryFConstruct a ball given the center point and a point p on the boundary. hgeometry1A d dimensional unit ball centered at the origin. hgeometry+Test if a point lies strictly inside a ball&(point2 0.5 0.0) `insideBall` unitBallTrue"(point2 1 0) `insideBall` unitBallFalse"(point2 2 0) `insideBall` unitBallFalse hgeometry&Test if a point lies in or on the ball hgeometry/Test if a point lies on the boundary of a ball.(point2 1 0) `onBall` unitBallTrue (point3 1 1 0) `onBall` unitBallFalse hgeometrytGiven three points, get the disk through the three points. If the three input points are colinear we return Nothing1disk (point2 0 10) (point2 10 0) (point2 (-10) 0)FJust (Ball {_center = Point2 [0.0,0.0] :+ (), _squaredRadius = 100.0}) hgeometry2Creates a circle from three points on the boundary hgeometrydA line segment may not intersect a circle, touch it, or intersect it properly in one or two points. hgeometry2No intersection, one touching point, or two points%None %&',-.1234567=>?@AHMPSUVX_gk^  hgeometryEconvenience function to construct a triangle without associated data. hgeometryCompute the area of a triangle  hgeometry2*the area of a triangle.  hgeometry9Checks if the triangle is degenerate, i.e. has zero area.  hgeometryhget the inscribed disk. Returns Nothing if the triangle is degenerate, i.e. if the points are colinear.  hgeometry[Given a point q and a triangle, q inside the triangle, get the baricentric cordinates of q  hgeometryGiven a vector of barricentric coordinates and a triangle, get the corresponding point in the same coordinate sytsem as the vertices of the triangle. hgeometryQTests if a point lies inside a triangle, on its boundary, or outside the triangle hgeometry<Test if a point lies inside or on the boundary of a triangle            &(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gkb hgeometry$Data that we store in the split tree #$&%'()*23654789:;<=BCD *)('#$&%<;=:78923654DCB'(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkE hgeometryCST monad with access to the vector storign the level of the points.F hgeometryConstruct a split treerunning time:  O(n \log n)G hgeometry5Given a split tree, generate the Well separated pairsrunning time: O(s^d n)H hgeometryKGiven the points, sorted in every dimension, recursively build a split treeThe algorithm works in rounds. Each round takes O(n) time, and halves the number of points. Thus, the total running time is O(n log n).The algorithm essentially builds a path in the split tree; at every node on the path that we construct, we split the point set into two sets (L,R) according to the longest side of the bounding box.The smaller set is "assigned" to the current node and set asside. We continue to build the path with the larger set until the total number of items remaining is less than n/2.`To start the next round, each node on the path needs to have the points assigned to that node, sorted in each dimension (i.e. the Vector (PointSeq))'s. Since we have the level assignment, we can compute these lists by traversing each original input list (i.e. one for every dimension) once, and partition the points based on their level assignment.I hgeometry2Assign the points to their the correct class. The $ class is considered the last classK hgeometry2Assign the points to their the correct class. The $ class is considered the last classM hgeometryGiven a sequence of points, whose index is increasing in the first dimension, i.e. if idx p < idx q, then p[0] < q[0]. Reindex the points so that they again have an index in the range [0,..,n'], where n' is the new number of points.Xrunning time: O(n' * d) (more or less; we are actually using an intmap for the lookups)alternatively: I can unsafe freeze and thaw an existing vector to pass it along to use as mapping. Except then I would have to force the evaluation order, i.e. we cannot be in M( for two of the nodes at the same time.0so, basically, run reIndex points in ST as well.N hgeometryAssigns the points to a level. Returns the list of levels used. The first level in the list is the level assigned to the rest of the nodes. Their level is actually still set to Nothing in the underlying array.O hgeometry9Remove already assigned pts from the ends of all vectors.P hgeometryAssign level l to point pQ hgeometryGet the level of a pointR hgeometry5Test if the point already has a level assigned to it.S hgeometry1Remove allready assigned points from the sequencepre: there are points remainingT hgeometryGiven the points, ordered by their j^th coordinate, split the point set into a "left" and a "right" half, i.e. the points whose j^th coordinate is at most the given mid point m, and the points whose j^th coordinate is larger than m.,We return a pair (Largest set, Smallest set)fi ndAndCompact works by simultaneously traversing the points from left to right, and from right to left. As soon as we find a point crossing the mid point we stop and return. Thus, in principle this takes only O(|Smallest set|) time.running time: O(|Smallest set|) + R, where R is the number of *old* points (i.e. points that should have been removed) in the list.U hgeometry*Find the widest dimension of the point set3pre: points are sorted according to their dimensionW hgeometry]get the extends of the set of points in every dimension, i.e. the left and right boundaries.3pre: points are sorted according to their dimensionY hgeometry4Test if the two sets are well separated with param sZ hgeometry1Test if the two boxes are sufficiently far appart] hgeometry)Computes the maximum width of a splitTree^ hgeometryComputes! the bounding box of a split tree` hgeometryTurn a traversal into lensK hgeometrynumber of classes hgeometrylevel assignment hgeometry input pointsN hgeometry"Number of items we need to collect hgeometry#Number of items we collected so far hgeometrynext level to use hgeometryLevels used so farT hgeometryWthe dimension we are in, i.e. so that we know which coordinate of the point to compare hgeometry the mid pointY hgeometryseparation factorEFGHIJKLMNOPQRSTUVWXYZ[\]^_`aFGHIJKLMENOPQRSTUVWXYZ[\]^_`a(None%&',-.1234567=>?@AHMPSUVX_gk/b hgeometryLine simplification with the well-known Douglas Peucker alogrithm. Given a distance value eps adn a polyline pl, constructs a simplification of pl (i.e. with vertices from pl) s.t. all other vertices are within dist eps to the original polyline.5Running time: O(n^2) worst case, O(n log n) expected.c hgeometry;Concatenate the two polylines, dropping their shared vertexd hgeometryJSplit the polyline at the given vertex. Both polylines contain this vertexe hgeometryGiven a sequence of points, find the index of the point that has the Furthest distance to the LineSegment. The result is the index of the point and this distance.bcdebcde)(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gkbf hgeometry7Data type representing the solution to a linear program fgihjkmlnopst fgihponjkmlts*(C) Frank Staalssee the LICENSE file Frank StaalsNone %&',-.1234567=>?@AHMPSUVX_gk hgeometryState during the LP algo hgeometrySolve a linear programx hgeometryPSolves a bounded linear program in 2d. Returns Nothing if there is no solution.pre: The linear program is bounded, meaning that *the first two constraints* m1,m2 make sure th the there is no arbitrarily large/good solution. I..e. these halfspaces bound the solution in the c direction.(note that if there is only one constraint, m1, the assumption that the LP is bounded means that the contraint must be perpendicular to the objective direction. Hence, any point on the bounding plane is a solution, and they are all equally good.)O(n) expected timey hgeometry&Solves a bounded linear program (like x) assuming that the first two constraints [m1,m2] make sure the solutions is bounded, and the other constraints already have been shuffled. hgeometry(What we do when we get a new halfspace h hgeometrycollect all intersecting halflines on the boundary l of h. If we return a Nothing there is no solution. Just [] indicates that somehow this halfspace h is contained in all other halfspaces.z hgeometrySGiven a vector v and two points a and b, determine which is smaller in direction v.{ hgeometrymComputes the common intersection of a nonempty list of halfines that are all colinear with the given line l.We return either the two halflines that prove that there is no counter example or we return one or two points that form form the boundary points of the range in which all halflines intersect. hgeometryQmaximum of a list using a given comparison ; if the list is empty returns Nothing| hgeometry8One dimensional linear programming on lines embedded in  \mathbb{R}^d.Given an objective vector c, a line l, and a collection of half-lines hls that are all sublines of l (i.e. halfspaces *on* l), compute if there is a point inside all these halflines. If so, we actually return the one that maximizes c.running time: O(n)} hgeometryLet l be the boundary of h, and assume that we know that the new point in the common intersection must lie on h, try to find this point. In partiuclar, we find the  point in the s^.direction vector. The funtion returns Nothing if no such point exists, i.e. if there is no point on l that is contained in all halfspaces..Note that this is essentially one dinsional LP hgeometryQAssumes that the first two constraints somehow bound the solution in direction c. hgeometryLet n(h)4 denote the normal of the line bounding a halfspace h.5This function tries to Find an "unbounded direction" d. If such a direction di exits the LP is unbounded, and we can produce evidence of this in the form of a half-line in direction d..More formally, we are looking for a direction d so that -  c \cdot d > 0 , and - d \cdot n(h) \geq 0, wherefor every half space h. hgeometryqEither finds an unbounded Haflline, or evidence the two halfspaces that provide evidence that no solution existsxyz{|}xy}|{z+(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk1 hgeometryEither a simple or multipolygon hgeometryOWe distinguish between simple polygons (without holes) and Polygons with holes. hgeometry,Access the i^th vertex on the outer boundary hgeometryGet all holes in a polygon hgeometryXThe vertices in the polygon. No guarantees are given on the order in which they appear! hgeometry9Creates a simple polygon from the given list of vertices.3pre: the input list constains no repeated vertices. hgeometryKThe edges along the outer boundary of the polygon. The edges are half open.running time: O(n) hgeometryLists all edges. The edges on the outer boundary are given before the ones on the holes. However, no other guarantees are given on the order.running time: O(n) hgeometryvPairs every vertex with its incident edges. The first one is its predecessor edge, the second one its successor edge.<mapM_ print . polygonVertices $ withIncidentEdges simplePolyPoint2 [0 % 1,0 % 1] :+ SP LineSegment (Closed (Point2 [1 % 1,11 % 1] :+ ())) (Closed (Point2 [0 % 1,0 % 1] :+ ())) LineSegment (Closed (Point2 [0 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,0 % 1] :+ ()))Point2 [10 % 1,0 % 1] :+ SP LineSegment (Closed (Point2 [0 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,0 % 1] :+ ())) LineSegment (Closed (Point2 [10 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,10 % 1] :+ ()))Point2 [10 % 1,10 % 1] :+ SP LineSegment (Closed (Point2 [10 % 1,0 % 1] :+ ())) (Closed (Point2 [10 % 1,10 % 1] :+ ())) LineSegment (Closed (Point2 [10 % 1,10 % 1] :+ ())) (Closed (Point2 [5 % 1,15 % 1] :+ ()))Point2 [5 % 1,15 % 1] :+ SP LineSegment (Closed (Point2 [10 % 1,10 % 1] :+ ())) (Closed (Point2 [5 % 1,15 % 1] :+ ())) LineSegment (Closed (Point2 [5 % 1,15 % 1] :+ ())) (Closed (Point2 [1 % 1,11 % 1] :+ ()))Point2 [1 % 1,11 % 1] :+ SP LineSegment (Closed (Point2 [5 % 1,15 % 1] :+ ())) (Closed (Point2 [1 % 1,11 % 1] :+ ())) LineSegment (Closed (Point2 [1 % 1,11 % 1] :+ ())) (Closed (Point2 [0 % 1,0 % 1] :+ ())) hgeometryUGiven the vertices of the polygon. Produce a list of edges. The edges are half-open. hgeometryATest if q lies on the boundary of the polygon. Running time: O(n)"point2 1 1 `onBoundary` simplePolyFalse"point2 0 0 `onBoundary` simplePolyTrue#point2 10 0 `onBoundary` simplePolyTrue#point2 5 13 `onBoundary` simplePolyFalse#point2 5 10 `onBoundary` simplePolyFalse#point2 10 5 `onBoundary` simplePolyTrue#point2 20 5 `onBoundary` simplePolyFalseTODO: testcases multipolygon hgeometryhCheck if a point lies inside a polygon, on the boundary, or outside of the polygon. Running time: O(n).!point2 1 1 `inPolygon` simplePolyInside!point2 0 0 `inPolygon` simplePoly OnBoundary"point2 10 0 `inPolygon` simplePoly OnBoundary"point2 5 13 `inPolygon` simplePolyInside"point2 5 10 `inPolygon` simplePolyInside"point2 10 5 `inPolygon` simplePoly OnBoundary"point2 20 5 `inPolygon` simplePolyOutsideUTODO: Add some testcases with multiPolygons TODO: Add some more onBoundary testcases hgeometry1Test if a point lies strictly inside the polgyon. hgeometryCompute the area of a polygon hgeometryCompute the signed area of a simple polygon. The the vertices are in clockwise order, the signed area will be negative, if the verices are given in counter clockwise order, the area will be positive. hgeometry)Compute the centroid of a simple polygon. hgeometry)Pick a point that is inside the polygon.g(note: if the polygon is degenerate; i.e. has <3 vertices, we report a vertex of the polygon instead.)&pre: the polygon is given in CCW orderrunning time: O(n) hgeometry!Test if the polygon is a trianglerunning time: O(1) hgeometryFind a diagonal of the polygon.&pre: the polygon is given in CCW orderrunning time: O(n) hgeometryVTest if the outer boundary of the polygon is in clockwise or counter clockwise order.running time: O(n) hgeometry,Orient the outer boundary to clockwise order hgeometry4Orient the outer boundary to counter clockwise order hgeometryDConvert a Polygon to a simple polygon by forgetting about any holes. hgeometry(Comparison that compares which point is larger) in the direction given by the vector u. hgeometryCFinds the extreme points, minimum and maximum, in a given directionrunning time: O(n) hgeometryassigns unique integer numbers to all vertices. Numbers start from 0, and are increasing along the outer boundary. The vertices of holes will be numbered last, in the same order.numberVertices simplePolySimplePolygon CSeq [Point2 [0 % 1,0 % 1] :+ SP 0 (),Point2 [10 % 1,0 % 1] :+ SP 1 (),Point2 [10 % 1,10 % 1] :+ SP 2 (),Point2 [5 % 1,15 % 1] :+ SP 3 (),Point2 [1 % 1,11 % 1] :+ SP 4 ()] hgeometryTest if a Simple polygon is star-shaped. Returns a point in the kernel (i.e. from which the entire polygon is visible), if it exists.O(n) expected time hgeometry)Polygons are per definition 2 dimensional((,(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gkS{  hgeometry'Data Type representing a convex polygon hgeometryCFinds the extreme points, minimum and maximum, in a given direction*pre: The input polygon is strictly convex.running time:  O(\log n) hgeometryBFinds the extreme maximum point in the given direction. Based on /http://geomalgorithms.com/a14-_extreme_pts.html*pre: The input polygon is strictly convex.running time:  O(\log^2 n) hgeometryRotating Right  - rotate clockwise-Merging two convex hulls, based on the paper:Two Algorithms for Constructing a Delaunay Triangulation Lee and Schachter International Journal of Computer and Information Sciences, Vol 9, No. 3, 1980O: (combined hull, lower tangent that was added, upper tangent thtat was added) hgeometry-Compute the lower tangent of the two polgyonspre: - polygons lp and rp have at least 1 vertex - lp and rp are disjoint, and there is a vertical line separating the two polygons. - The vertices of the polygons are given in clockwise orderRRunning time: O(n+m), where n and m are the sizes of the two polygons respectively hgeometry-Compute the upper tangent of the two polgyonspre: - polygons lp and rp have at least 1 vertex - lp and rp are disjoint, and there is a vertical line separating the two polygons. - The vertices of the polygons are given in clockwise orderRRunning time: O(n+m), where n and m are the sizes of the two polygons respectively hgeometry]Computes the Minkowski sum of the two input polygons with $n$ and $m$ vertices respectively.%pre: input polygons are in CCW order.running time: O(n+m). hgeometryERotate to the rightmost point (rightmost and topmost in case of ties) hgeometry=Rotate to the leftmost point (and bottommost in case of ties) hgeometry=Rotate to the bottommost point (and leftmost in case of ties) hgeometry.Helper to get the vertices of a convex polygon hgeometry)Polygons are per definition 2 dimensional (C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkU *+,-.23456789:;<=>UVWXYZ[\]^_`abcdefgij{|}~[\]^`cabdefghijklmnopqrstuvwxyz{FGHIKLMNkUVWXYZ[\]^_`abcdefgij{|}~FGHIKLMN-(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gk`5 hgeometryeThe result of a smallest enclosing disk computation: The smallest ball and the points defining it hgeometryList of two or three elements  .(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkg hgeometryHorrible O(n^4) implementation that simply tries all disks, checks if they enclose all points, and takes the largest one. Basically, this is only useful to check correctness of the other algorithm(s) hgeometryBGiven a list of canidate enclosing disks, report the smallest one. hgeometry#check if a disk encloses all points/(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gkpH hgeometryO(n) expected time algorithm to compute the smallest enclosing disk of a set of points. we need at least two points. implemented using randomized incremental construction hgeometrySmallest enclosing disk. hgeometry6Smallest enclosing disk, given that p should be on it. hgeometry;Smallest enclosing disk, given that p and q should be on it hgeometryConstructs the initial  from two points0None%&',-.1234567=>?@AHMPSUVX_gkud hgeometryBComputes the Euclidean diametral pair by naively trying all pairs.running time: O(n^2) hgeometrymGiven a distance function and a list of points pts, computes the diametral pair by naively trying all pairs.running time: O(n^2)1None%&',-.1234567=>?@AHMPSUVX_gkw^ hgeometry O(n \log n) hgeometry O(n \log n)2None%&',-.1234567=>?@AHMPSUVX_gk}  hgeometry O(n \log n)W time ConvexHull using Graham-Scan. The resulting polygon is given in clockwise order. hgeometrygHelper function so that that can compute both the upper or the lower hull, depending on the function f hgeometry0Precondition: The list of input points is sorted3None%&',-.1234567=>?@AHMPSUVX_gkW hgeometryOGiven a list of non-vertical lines, computes the lower envelope using duality. O(n\log n) hgeometryGiven a list of non-vertical lines, computes the lower envelope by computing the upper convex hull. It uses the given algorithm to do so@running time: O(time required by the given upper hull algorithm) hgeometry=Computes the vertices of the envelope, in left to right order hgeometryrGiven two non-parallel lines, compute the intersection point and return the pair of a's associated with the lines4(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkM hgeometry O(n \log n)^ time ConvexHull using divide and conquer. The resulting polygon is given in clockwise order.5(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk hgeometry6Given a set of red points and a set of blue points in  \mathbb{R}^2x finds a separating line (if it exists). The result is non-strict in the sense that there may be points *on* the line.running time: O(n) expected time, where n is the total number of points. hgeometry6Given a set of red points and a set of blue points in  \mathbb{R}^2 finds a separating line (if it exists) that has all red points *right* (or on) the line, and all blue points left (or on) the line.running time: O(n) expected time, where n is the total number of points. hgeometrygiven a red and blue point that are *NOT* vertically alligned, and all red and all blue points, try to find a non-vertical separating line.running time: O(n) expected time, where n is the total number of points. hgeometry9Computes a strict vertical separating line, if one exists hgeometrypTest if there is a vertical separating line that has all red points to its right (or on it) and all blue points to its left (or on it). This function also returns the two extremal points; in case a line is returned, the line actually goes through the blue (second) point, if there is no line, this pair provides evidence that there is no vertical separating line.8The line we return actually goes through one blue point. hgeometry<Get the the leftmost red point and the rightmost blue point. hgeometry red point r hgeometrya blue point b6(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk hgeometryA pair of points hgeometry/Naive algorithm to compute the closest pair in d dimensions. Runs in O(n^2) time (for any constant dK). Note that we need at least two elements for there to be a closest pair. hgeometryCreate a pair of points hgeometryxProduce all lists from a vec of elements. Since the Vec contains at least two elements, the resulting list is non-empty7(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkw hgeometryHA vertex, represented by an id, location, its adjacencies, and its data. hgeometryPadjacent vertices + data on the edge. Adjacencies are given in arbitrary order  8(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gk4! hgeometry&Note that the functor instance is in v* hgeometry#Embedded, *connected*, planar graph6 hgeometryrConstruct a plane graph from a simple polygon. It is assumed that the polygon is given in counterclockwise order..the interior of the polygon will have faceId 0Ipre: the input polygon is given in counterclockwise order running time: O(n). hgeometry+Constructs a planar from the given vertices7 hgeometry"Constructs a connected plane graph3pre: The segments form a single connected componentrunning time:  O(n\log n)8 hgeometryGet the number of verticesnumVertices smallG49 hgeometryGet the number of DartsnumDarts smallG10: hgeometryGet the number of EdgesnumEdges smallG5; hgeometryGet the number of facesnumFaces smallG3< hgeometryEnumerate all verticesvertices' smallG-[VertexId 0,VertexId 1,VertexId 2,VertexId 3]= hgeometry[Enumerate all vertices, together with their vertex data >>> mapM_ print $ vertices smallG (VertexId 0,VertexData {_location = Point2 [0,0], _vData = 0}) (VertexId 1,VertexData {_location = Point2 [2,2], _vData = 1}) (VertexId 2,VertexData {_location = Point2 [2,0], _vData = 2}) (VertexId 3,VertexData {_location = Point2 [-1,4], _vData = 3})> hgeometryEnumerate all darts? hgeometry&Get all darts together with their data@ hgeometry6Enumerate all edges. We report only the Positive dartsA hgeometry6Lens to access the raw dart data, use at your own riskB hgeometrylens to access the Dart DataC hgeometryLens to access face dataE hgeometryMEnumerate all edges with their edge data. We report only the Positive darts.mapM_ print $ edges smallG(Dart (Arc 0) +1,"0->2")(Dart (Arc 1) +1,"0->1")(Dart (Arc 2) +1,"0->3")(Dart (Arc 4) +1,"1->2")(Dart (Arc 3) +1,"1->3")F hgeometry&Enumerate all faces in the plane graphG hgeometryAll faces with their face data.mapM_ print $ faces smallG(FaceId 0,"OuterFace")(FaceId 1,"A")(FaceId 2,"B")H hgeometryHReports the outerface and all internal faces separately. running time: O(n)I hgeometry+Reports all internal faces. running time: O(n)J hgeometry=The tail of a dart, i.e. the vertex this dart is leaving fromrunning time: O(1)tailOf (dart 0 "+1") smallG VertexId 0K hgeometry%The vertex this dart is heading in torunning time: O(1)headOf (dart 0 "+1") smallG VertexId 2L hgeometry(endPoints d g = (tailOf d g, headOf d g)running time: O(1)endPoints (dart 0 "+1") smallG(VertexId 0,VertexId 2)M hgeometryCAll edges incident to vertex v, in counterclockwise order around v.running time: O(k), where k is the output size!incidentEdges (VertexId 1) smallG1[Dart (Arc 1) -1,Dart (Arc 4) +1,Dart (Arc 3) +1]N hgeometryLAll incoming edges incident to vertex v, in counterclockwise order around v.!incomingEdges (VertexId 1) smallG[Dart (Arc 1) -1]O hgeometryLAll outgoing edges incident to vertex v, in counterclockwise order around v.!outgoingEdges (VertexId 1) smallG![Dart (Arc 4) +1,Dart (Arc 3) +1]P hgeometryYGets the neighbours of a particular vertex, in counterclockwise order around the vertex.running time: O(k), where k is the output size neighboursOf (VertexId 1) smallG"[VertexId 0,VertexId 2,VertexId 3]Q hgeometryyGiven a dart d that points into some vertex v, report the next dart in the cyclic order around v in clockwise direction.running time: O(1)%nextIncidentEdge (dart 1 "+1") smallGDart (Arc 2) +1R hgeometryvGiven a dart d that points into some vertex v, report the next dart in the cyclic order around v (in clockwise order)running time: O(1)%prevIncidentEdge (dart 1 "+1") smallGDart (Arc 0) +1S hgeometry The face to the left of the dartrunning time: O(1).leftFace (dart 1 "+1") smallGFaceId 2leftFace (dart 1 "-1") smallGFaceId 1leftFace (dart 2 "+1") smallGFaceId 0leftFace (dart 2 "-1") smallGFaceId 2T hgeometry!The face to the right of the dartrunning time: O(1).rightFace (dart 1 "+1") smallGFaceId 1rightFace (dart 1 "-1") smallGFaceId 2rightFace (dart 2 "+1") smallGFaceId 2rightFace (dart 2 "-1") smallGFaceId 0U hgeometry Get the next edge along the facerunning time: O(1).nextEdge (dart 1 "+1") smallGDart (Arc 4) +1V hgeometry$Get the previous edge along the facerunning time: O(1).prevEdge (dart 1 "+1") smallGDart (Arc 0) -1W hgeometrytThe darts bounding this face, for internal faces in clockwise order, for the outer face in counter clockwise order.running time: O(k), where k is the output size.X hgeometryEGenerates the darts incident to a face, starting with the given dart.O(k), where k is the number of darts reportedY hgeometry`Gets a dart bounding this face. I.e. a dart d such that the face lies to the right of the dart.Z hgeometrywThe vertices bounding this face, for internal faces in clockwise order, for the outer face in counter clockwise order.running time: O(k), where k is the output size.] hgeometryTraverse the vertices(^.vertexData)  $ traverseVertices (i x -> Just (i,x)) smallG Just [(VertexId 0,0),(VertexId 1,1),(VertexId 2,2),(VertexId 3,3)] >>> traverseVertices (i x -> print (i,x)) smallG >> pure () (VertexId 0,0) (VertexId 1,1) (VertexId 2,2) (VertexId 3,3)^ hgeometryTraverses the darts5traverseDarts (\d x -> print (d,x)) smallG >> pure () (Dart (Arc 0) +1,"0->2")(Dart (Arc 0) -1,"2->0")(Dart (Arc 1) +1,"0->1")(Dart (Arc 1) -1,"1->0")(Dart (Arc 2) +1,"0->3")(Dart (Arc 2) -1,"3->0")(Dart (Arc 3) +1,"1->3")(Dart (Arc 3) -1,"3->1")(Dart (Arc 4) +1,"1->2")(Dart (Arc 4) -1,"2->1")_ hgeometryTraverses the faces5traverseFaces (\i x -> print (i,x)) smallG >> pure ()(FaceId 0,"OuterFace")(FaceId 1,"A")(FaceId 2,"B")` hgeometry.Getter for the data at the endpoints of a dartrunning time: O(1)a hgeometry/Data corresponding to the endpoints of the dartrunning time: O(1)b hgeometrygets the id of the outer facerunning time: O(n)c hgeometry[gets a dart incident to the outer face (in particular, that has the outerface on its left)running time: O(n)d hgeometry"Reports all edges as line segments!mapM_ print $ edgeSegments smallGa(Dart (Arc 0) +1,LineSegment (Closed (Point2 [0,0] :+ 0)) (Closed (Point2 [2,0] :+ 2)) :+ "0->2")a(Dart (Arc 1) +1,LineSegment (Closed (Point2 [0,0] :+ 0)) (Closed (Point2 [2,2] :+ 1)) :+ "0->1")b(Dart (Arc 2) +1,LineSegment (Closed (Point2 [0,0] :+ 0)) (Closed (Point2 [-1,4] :+ 3)) :+ "0->3")a(Dart (Arc 4) +1,LineSegment (Closed (Point2 [2,2] :+ 1)) (Closed (Point2 [2,0] :+ 2)) :+ "1->2")b(Dart (Arc 3) +1,LineSegment (Closed (Point2 [2,2] :+ 1)) (Closed (Point2 [-1,4] :+ 3)) :+ "1->3")e hgeometry[Given a dart and the graph constructs the line segment representing the dart. The segment \overline{uv}) is has u as its tail and v as its head.O(1)f hgeometryThe polygon describing the face runningtime: O(k), where k is the size of the face.g hgeometryAlias for rawFace Boundary runningtime: O(k), where k is the size of the face.h hgeometry#Lists all faces of the plane graph.i hgeometry_Labels the edges of a plane graph with their distances, as specified by the distance function.6 hgeometry data inside hgeometrydata outside the polygonO !"*+,-.56789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiO*+5!"-,.678:;9<=@EFGIH>?]^_KJLMNOPQRSTUVWXYZbc[\`aDCBAedgfh i9(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk,^o hgeometry%Reads a plane graph from a bytestringp hgeometry$Writes a plane graph to a bytestringq hgeometryTransforms the planar graph into a format taht can be easily converted into JSON format. For every vertex, the adjacent vertices are given in counter clockwise order.See toAdjacencyLists' for notes on how we handle self-loops.running time: O(n)s hgeometry1Orders the adjacencylists of a plane graph (with nU vertices) (in Adj repr) so that they are all counter-clockwise around the vertices.running time:  O(n \log n)opqrsopqrsL(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_gk.R !"*+,-.56789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghiopqrR*+5!"-,.67qr8:;9<=@EFGIH>?]^_KJLMNOPQRSTUVWXYZbc[\`aDCBAedgfh ipo:(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gk:v hgeometry=The Face data consists of the data itself and a list of holesz hgeometry>Helper type for the data that we store in a planar subdivision hgeometryComponentId type hgeometry6Helper data type and type family to Wrap a proxy type. hgeometryget the dataVal of a Raw hgeometryFace data, if the face is an inner face, store the component and faceId of it. If not, this face must be the outer face (and thus we can find all the face id's it correponds to through the FaceData).vwyxz{~}|z{~}|vwyx;(C) Frank Staalssee the LICENSE file Frank StaalsNone#%&',-.1234567=>?@AHMPSUVX_ghkt- hgeometryA planarsubdivision is essentially a bunch of plane-graphs; one for every connected component. These graphs store the global ID's (darts, vertexId's, faceId's) in their data values. This essentially gives us a mapping between the two.note that a face may actually occur in multiple graphs, hence when we store the edges to the the holes, we store the global edgeId's rather than the local edgeId (dart)'s.%invariant: the outerface has faceId 0 hgeometryA connected component.For every face f, and every hole in this face, the facedata points to a dart d on the hole s.t. this dart has the face f on its left. i.e. leftFace d = f hgeometryNData type that expresses whether or not we are inside or outside the polygon. hgeometry0Constructs a planarsubdivision from a PlaneGraph runningTime: O(n) hgeometrynGiven a (connected) PlaneGraph and a dart that has the outerface on its left | Constructs a planarsubdivision runningTime: O(n) hgeometryrConstruct a plane graph from a simple polygon. It is assumed that the polygon is given in counterclockwise order..the interior of the polygon will have faceId 0Ipre: the input polygon is given in counterclockwise order running time: O(n). hgeometry*Constructs a connected planar subdivision.Cpre: the segments form a single connected component running time:  O(n\log n) hgeometryGet the number of verticesnumVertices myGraph1 hgeometryGet the number of verticesnumVertices myGraph4 hgeometryGet the number of DartsnumDarts myGraph12 hgeometryGet the number of EdgesnumEdges myGraph6 hgeometryGet the number of facesnumFaces myGraph4 hgeometryEnumerate all verticesvertices' myGraph-[VertexId 0,VertexId 1,VertexId 2,VertexId 3] hgeometry7Enumerate all vertices, together with their vertex data hgeometryEnumerate all darts hgeometry6Enumerate all edges. We report only the Positive darts hgeometryMEnumerate all edges with their edge data. We report only the Positive darts.mapM_ print $ edges myGraph(Dart (Arc 2) +1,"c+")(Dart (Arc 1) +1,"b+")(Dart (Arc 0) +1,"a+")(Dart (Arc 5) +1,"g+")(Dart (Arc 4) +1,"e+")(Dart (Arc 3) +1,"d+") hgeometryDEnumerates all faces with their face data exlcluding the outer face hgeometrylens to access the Dart Data hgeometrySLens to the facedata of the faces themselves. The indices correspond to the faceIds hgeometry[Lens to the facedata of the vertexdata themselves. The indices correspond to the vertexId's hgeometry=The tail of a dart, i.e. the vertex this dart is leaving fromrunning time: O(1) hgeometry%The vertex this dart is heading in torunning time: O(1) hgeometry(endPoints d g = (tailOf d g, headOf d g)running time: O(1) hgeometryCAll edges incident to vertex v, in counterclockwise order around v.running time: O(k), where k! is the number of edges reported. hgeometrydGiven a dart d that points into some vertex v, report the next dart e in the cyclic order around v.running time: O(1) hgeometryLAll incoming edges incident to vertex v, in counterclockwise order around v. hgeometryLAll outgoing edges incident to vertex v, in counterclockwise order around v. hgeometryYGets the neighbours of a particular vertex, in counterclockwise order around the vertex.running time: O(k), where k is the output size hgeometry The face to the left of the dartrunning time: O(1). hgeometry!The face to the right of the dartrunning time: O(1). hgeometryThe darts on the outer boundary of the face, for internal faces the darts are in clockwise order. For the outer face the darts are in counterclockwise order, and the darts from various components are in no particular order.running time: O(k), where k is the output size. hgeometry3Get the local face and component from a given face. hgeometryThe vertices of the outer boundary of the face, for internal faces in clockwise order, for the outer face in counter clockwise order.running time: O(k), where k is the output size. hgeometryLists the holes in this face, given as a list of darts to arbitrary darts on those faces. The returned darts are on the outside of the hole, i.e. they are incident to the given input face:/all (\d -> leftFace d ps == fi) $ holesOf fi psrunning time: O(k), where k! is the number of darts returned. hgeometryENote that using the setting part of this lens may be very expensive!! hgeometry.Getter for the data at the endpoints of a dartrunning time: O(1) hgeometry/data corresponding to the endpoints of the dartrunning time: O(1) hgeometrygets the id of the outer facerunning time: O(1) hgeometry"Reports all edges as line segments hgeometryLGiven a dart and the subdivision constructs the line segment representing itO(1) hgeometryEGenerates the darts incident to a face, starting with the given dart.O(k), where k is the number of darts reported hgeometry)Constructs the outer boundary of the faceO(k), where k4 is the complexity of the outer boundary of the face hgeometry)Constructs the boundary of the given faceO(k), where k is the complexity of the face hgeometry5Lists all *internal* faces of the planar subdivision. hgeometry data inside hgeometrydata outside the polygon[ !"*,-vwz{|}~[!"-,vw* z{|}~<(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gk hgeometry1Merge a pair of *disjoint* planar subdivisions, unifying their outer face. The given function is used to merge the data corresponding to the outer face. The subdivisions are merged pairwise, no guarantees are given about the order in which they are merged. Hence, it is expected that f is commutative.running time:  O(n\log n), where n( is the total size of the subdivisions. hgeometryMerge a pair of *disjoint* planar subdivisions, unifying their outer face. For the outerface data it simply takes the data of the first subdivision. runningtime: O(n) hgeometryMerge a pair of *disjoint* planar subdivisions. In particular, this function unifies the structure assuming that the two subdivisions share the outer face. runningtime: O(n) hgeometryjTakes care of actually combining the vectors with data. only thing left is how to merge the raw face data hgeometryShift the indices in a planar subdiv by the given numbers (componentId;vertexId,darts,faceIds). Note that the result is not really a valid planar subdivision, so be careful when using this! hgeometryThe disjoint "holes" hgeometryHow to merge the face data hgeometry-Face in which to embed the given subdivisions hgeometrythe outer subdivision hgeometryThe hole hgeometry-How to merge the face data (hole value first) hgeometry-Face in which to embed the given subdivisions hgeometrythe outer subdivision hgeometry'how to merge the data of the outer face hgeometryhow to merge the raw face data=(C) Frank Staalssee the LICENSE file Frank StaalsNone"%&',-.1234567=>?@AHMPSUVX_ghk hgeometry5Constructs a planar subdivision from a collection of k( disjoint polygons of total complexity O(n).Jpre: The boundary of the polygons is given in counterclockwise orientation runningtime: O(n\log n\log k)& in case of polygons with holes, and  O(n\log k) in case of simple polygons. hgeometry Version of  that accepts  s as input. hgeometryConstruct a planar subdivision from a polygon. Since our PlanarSubdivision models only connected planar subdivisions, this may add dummy/invisible edges.Ppre: The outer boundary of the polygons is given in counterclockwise orientationrunning time: O(n) for a simple polygon,  O(n\log n) for a polygon with holes. hgeometryouter face data hgeometrythe disjoint polygons hgeometryouter face data hgeometrythe disjoint polygons hgeometry data inside hgeometrydata outside the polygon^ !"*,-vwz{|}~>(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gkt hgeometry;Data type representing a two dimensional planar arrangement hgeometryBuilds an arrangement of n linesrunning time:  O(n^2\log n hgeometryConstructs the arrangemnet inside the box. note that the resulting box may be larger than the given box to make sure that all vertices of the arrangement actually fit.running time:  O(n^2\log n  hgeometryConstructs the arrangemnet inside the box. (for parts to be useful, it is assumed this boxfits at least the boundingbox of the intersections in the Arrangement) hgeometry5Constructs a boundingbox containing all intersectionsrunning time: O(n^2), where n is the number of input lines hgeometryComputes all intersections hgeometry1Computes the intersections with a particular side hgeometryHConstructs the unbounded intersections. Reported in clockwise direction. hgeometryGLinks the vertices of the outer boundary with those in the subdivision hgeometrynGiven a predicate that tests if two elements of a CSeq match, find a rotation of the seqs such at they match.Running time: O(n) hgeometry\Given an Arrangement and a line in the arrangement, follow the line through he arrangement. hgeometry4Find the starting point of the line the arrangement hgeometrybGiven a point on the boundary of the boundedArea box; find the vertex this point corresponds to.running time:  O(\log n)basically; maps every point to a tuple of the point and the side the point occurs on. We then binary search to find the point we are looking for. hgeometryOFind the starting dart of the given vertex v. Reports a dart s.t. tailOf d = v running me: O(k) where k is the degree of the vertex hgeometryGiven a dart d that incoming to v (headOf d == v), find the outgoing dart colinear with the incoming one. Again reports dart d' s.t. tailOf d' = vrunning time: O(k)1, where k is the degree of the vertex d points to            M(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gke  ?None%&',-.1234567=>?@AHMPSUVX_gk hgeometryUGiven a list of original edges and a list of diagonals, creates a planar-subdivisionrunning time:  O(n\log n)  hgeometryUGiven a list of original edges and a list of diagonals, creates a planar-subdivisionrunning time:  O(n\log n) hgeometry3A counter-clockwise edge along the outer boundary hgeometryremaining original edges hgeometry diagonals  hgeometry3A counter-clockwise edge along the outer boundary hgeometryremaining original edges hgeometry diagonals  @None!%&',-.1234567=>?@AHMPSUVX_gk ' hgeometry*for every e_i, the id of the helper vertex/ hgeometry$assigns a vertex type to each vertex&pre: the polygon is given in CCW orderrunning time: O(n).0 hgeometry$assigns a vertex type to each vertex&pre: the polygon is given in CCW orderrunning time: O(n).1 hgeometryp  q = p.y < q.y || p.y == q.y && p.x q.y; hgeometrymGiven a polygon, find a set of non-intersecting diagonals that partition the polygon into y-monotone pieces.running time:  O(n\log n)< hgeometryPComputes a set of diagionals that decompose the polygon into y-monotone pieces.running time:  O(n\log n)F hgeometry1Adds edge (i,j) if e_j's helper is a merge vertexG hgeometry-Get the helper of edge i, and its vertex typeK hgeometry`finds the edge j to the left of v_i, and connect v_i to it if the helper of j is a merge vertexL hgeometryBreturns True if v the interior of the polygon is to the right of v'$%'&().-,+*/016789:;<=>?@ABCDEFGHIJKLMN').-,+*/01($%'&98:;<76=>?@ABCDEFGHIJKLMNANone%&',-.1234567=>?@AHMPSUVX_gkU hgeometryTriangulates a polygon of n verticesrunning time:  O(n \log n)V hgeometryTriangulates a polygon of n verticesrunning time:  O(n \log n)W hgeometryoGiven a y-monotone polygon in counter clockwise order computes the diagonals to add to triangulate the polygon-pre: the input polygon is y-monotone and has n \geq 3 verticesrunning time: O(n)\ hgeometry5test if m does not block the line segment from v to u] hgeometry8given a comparison function, merge the two ordered lists^ hgeometrykWhen the polygon is in counter clockwise order we return (leftChain,rightChain) ordered from the top-down.if there are multiple points with the maximum yCoord we pick the rightmost one, if there are multiple point with the minimum yCoord we pick the leftmost one.running time: O(n)OPQRSTUVWXYZ[\]^_TQRSUVWPOXYZ[\]^_BNone%&',-.1234567=>?@AHMPSUVX_gkb hgeometryTriangulates a polygon of n verticesrunning time:  O(n \log n)c hgeometryTriangulates a polygon of n verticesrunning time:  O(n \log n)d hgeometryMComputes a set of diagaonals that together triangulate the input polygon of n vertices.running time:  O(n \log n)e hgeometryMComputes a set of diagaonals that together triangulate the input polygon of ns vertices. Returns a copy of the input polygon, whose boundaries are oriented in counter clockwise order, as well.running time:  O(n \log n)bcdebcdeC(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gk_f hgeometryeNeighbours are stored in clockwise order: i.e. rotating right moves to the next clockwise neighbour.m hgeometryRotating Right  - rotate clockwisep hgeometry*ST' is a strict triple (m,a,x) containing:fm: a Map, mapping edges, represented by a pair of vertexId's (u,v) with u < v, to arcId's."a: the next available unused arcID0x: the data value we are interested in computing~ hgeometry2convert the triangulation into a planarsubdivisionrunning time: O(n). hgeometry,convert the triangulation into a plane graphrunning time: O(n).fgjihklmpqrsvutwxyz{|}~mlkfgjihzyxw{|}rsvutqp~DNone%&',-.1234567=>?@AHMPSUVX_gk)7 hgeometryNaive O(n^4) time implementation of the delaunay triangulation. Simply tries each triple (p,q,r) and tests if it is delaunay, i.e. if there are no other points in the circle defined by p, q, and r.pre: the input is a *SET*, i.e. contains no duplicate points. (If the input does contain duplicate points, the implementation throws them away) hgeometrypGiven a list of edges, as vertexId pairs, construct a vector with the adjacency lists, each in CW sorted order. hgeometryGiven a particular point u and a list of points vs, sort the points vs in CW order around u. running time: O(m log m), where m=|vs| is the number of vertices to sort. hgeometry0Given a list of faces, construct a list of edges hgeometryaTest if the given three points form a triangle in the delaunay triangulation. running time: O(n)ENone%&',-.1234567=>?@AHMPSUVX_gkKF hgeometry7Computes the delaunay triangulation of a set of points.Running time:  O(n \log n)C (note: We use an IntMap in the implementation. So maybe actually  O(n \log^2 n))pre: the input is a *SET*, i.e. contains no duplicate points. (If the input does contain duplicate points, the implementation throws them away) hgeometryMapping that says for each vtx in the convex hull what the first entry in the adj. list should be. The input polygon is given in Clockwise order hgeometryXGiven a polygon; construct the adjacency list representation pre: at least two elements hgeometry&Merge the two delaunay triangulations.running time: O(n), (although we cheat a bit by using a IntMap) hgeometry'Merges the two delaunay traingulations. hgeometry'rotates'= around r and removes all neighbours of r that violate the delaunay condition. Returns the first vertex (as a Neighbour of r) that should remain in the Delaunay Triangulation, as well as a boolean A that helps deciding if we merge up by rotating left or rotating right (See description in the paper for more info) hgeometry&The code that does the actual rotating hgeometrySymmetric to rotateR hgeometry=The code that does the actual rotating. Symmetric to rotateR' hgeometryereturns True if the forth point (vertex) does not lie in the disk defined by the first three points. hgeometry(Inserts an edge into the right position. hgeometryNmake sure that the first vtx in the adj list of v is its predecessor on the CH hgeometryhInserts an edge (and makes sure that the vertex is inserted in the correct. pos in the adjacency lists) hgeometryDeletes an edge hgeometry!Lifted version of Convex.IsLeftOf hgeometry"Lifted version of Convex.IsRightOf hgeometryan unsafeO version of rotateTo that assumes the element to rotate to occurs in the list. hgeometryIAdjacency lists are stored in clockwise order, so pred means rotate right hgeometryKAdjacency lists are stored in clockwise order, so pred and succ rotate left hgeometry%Removes duplicates from a sorted list hgeometry lower tangent hgeometry upper tangentF(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkS hgeometryComputes the Euclidean Minimum Spanning Tree. We compute the Delaunay Triangulation (DT), and then extract the EMST. Hence, the same restrictions apply as for the DT:pre: the input is a *SET*, i.e. contains no duplicate points. (If the input does contain duplicate points, the implementation throws them away)running time:  O(n \log n)G(C) Frank Staalssee the LICENSE file Frank StaalsNone!%&',-.1234567=>?@AHMPSUVX_gkg;  hgeometry0A basic camera data type. The fields stored are:the camera position,Hthe raw camera normal, i.e. a unit vecotr into the center of the screen,Kthe raw view up vector indicating which side points "upwards" in the scene,bthe viewplane depth (i.e. the distance from the camera position to the plane on which we project),;the near distance (everything closer than this is clipped),Dthe far distance (everything further away than this is clipped), andthe screen dimensions. hgeometry1unit vector from camera into center of the screen hgeometry!viewUp; assumed to be unit vector hgeometryVLens to get and set the Camera normal, makes sure that the vector remains normalized. hgeometryQLens to get and set the viewUp vector. Makes sure the vector remains normalized. hgeometry+Full transformation that renders the figure hgeometry2Translates world coordinates into view coordinates hgeometry(Transformation into viewport coordinates hgeometry#constructs a perspective projection hgeometry[Rotates coordinate system around the camera, such that we look in the negative z direction hgeometryFlips the y and z axis.H(C) Frank Staalssee the LICENSE file Frank StaalsNone%&',-.1234567=>?@AHMPSUVX_gkm hgeometry"Rendering function for a triangle. hgeometryRender a point hgeometryRenders a line segment hgeometryGeneric Rendering Function hgeometryProjection function hgeometryThe camera transform hgeometryThe thing we wish to transformNOPNOQNORNOSNOTNOUNOVNOWNOXNOYNOZNO[NO\NO]NO^NO_NO`NOaNObNOcNOJNOJNOdNOeffghijkllmnopqrstuvwxyz{|}~x                        ! " # $ % & ' ( ) * + , " - . . / 0 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N     O P Q R S T U V W W X Y Z [ \ ] ^ _ ` a b c d 6 e f g h i j 7 8 9 > k l m n o p q r s t u v w x y z { | . } / 1 2 3 ~ . 4  7 8 9  5 6 > ? @ A : F  N H  J P G I K Q L R M S T                                                                     !"#$%&'()*+,-./01234566789:;<=>??@ABCDEFFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrsstuvwxyz{|}~      !"#$%&''()*+,-./0123456789:;<==>?@ABCDEFGHIJKLMNOPQRSTUVWXXYZ[\]^^_`abcdefghijkl m m n o p q r s t u v w x y z { | } ~ !!!!!!!!!!!!!!!!!!!"""####################################$$$$$$$$$$$$$$$$$$$$$$$$$a$$$$$9$$$$$$$$%%%%%%%%%%%%%%%%%%%%%&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&f&l&&&&&&&& & & & ' ''''''''''''''''''' '!'"'#'$'%'&'''(')(*( (+(,)-).)/)0)1)1)2)3)4)5)6)7)8)9):);)<)=*>*?*@*A*B*C*D*E+F+G+H+I+H+G+J+K+L+M+N+O+P+Q+R+S+*+T+U+V+W+X+Y+Z++[+\+]+^+_+`+a+b+c+d+e+f+g+h+i+j+k+l+m+n+o+p+q+r+s,t,t,u,v,w,x,y,z,{,|,}, ,~,,,,,,,,------b-a---------....../////000112223333334455555566866NNNNNNNN7777777777NNNNNNNNNNNNNNNNNNN888888888888888888888888888888888888888888888888888888888 8 8 8 8 8888888888888888899 9!9"9#9$9%:&:&:':(:):):*:+:,:-:-:.:/:0:1:2:3:4:5:6:7:8:9:::;:<:=:>:?:@:A:B:C:D:E:F:G:H:I:I:J:K::L:M:N:O:P:Q:R:S:T:U:V:W;X;X;Y;Z;[;\;];^;;;_;;`;a;b;c;d;;;e;;;;;;;;;;;;;;;;;;;;;;;;;;f; ;g; ;h;;;;;;;;;;i;j;k;l;m;n;o;p<q<r<s< <t=u=v=w=x=y>z>z>{>|>}>~>>>>>>>>>>>>>>>>>>>>>>>>>>>>????????@@]@@@@@@@@ @@@@@@@@@@@@@(@@@@@@@@@@@@@@@@@@@@AAAAfAlAAAAAAAAAAAAAABBBBCCCCCCCCCCCCCCCCCCCCCCCCCCDDDDDEEEEEEE EEEEEEEEEEEEEEEEEEEEEFFG G G G G G GGGGGGGGGGGGGGHHHHN !N "N #N $N N %N &N &N 'N (N )NO*NO+,-./0123456789:$;$<=>?*@*A*B*C*D=EF*G*H*I+J,K,L,M,N2O2P8Q;R; <S<TGUGVWhgeometry-0.9.0.0-inplaceData.Geometry.LineSegmentData.Geometry.Interval.UtilData.Geometry.PropertiesData.Geometry.IntervalData.Geometry.IntervalTreeData.Geometry.RangeTree.Measure!Data.Geometry.SegmentTree.GenericData.Geometry.Vector Data.Geometry Data.Geometry.Vector.VectorFixed&Data.Geometry.Vector.VectorFamilyPeano!Data.Geometry.Vector.VectorFamilyData.Geometry.PointData.Geometry.TransformationData.Geometry.BoundaryData.Geometry.RangeTree.GenericData.Geometry.RangeTree,Algorithms.Geometry.FrechetDistance.Discrete0Algorithms.Geometry.ClosestPair.DivideAndConquer Data.Geometry.PrioritySearchTreeData.Geometry.Line.InternalData.Geometry.SubLineData.Geometry.Box.Internal1Algorithms.Geometry.LineSegmentIntersection.Types1Algorithms.Geometry.LineSegmentIntersection.Naive:Algorithms.Geometry.LineSegmentIntersection.BentleyOttmannData.Geometry.BoxData.Geometry.PolyLineData.Geometry.LineData.Geometry.SlabData.Geometry.HyperPlaneData.Geometry.HalfLineData.Geometry.HalfSpaceData.Geometry.DualityData.Geometry.KDTreeData.Geometry.BallData.Geometry.Triangle8Algorithms.Geometry.WellSeparatedPairDecomposition.Types7Algorithms.Geometry.WellSeparatedPairDecomposition.WSPD9Algorithms.Geometry.PolyLineSimplification.DouglasPeucker+Algorithms.Geometry.LinearProgramming.Types-Algorithms.Geometry.LinearProgramming.LP2DRICData.Geometry.PolygonData.Geometry.Polygon.Convex/Algorithms.Geometry.SmallestEnclosingBall.Types/Algorithms.Geometry.SmallestEnclosingBall.NaiveKAlgorithms.Geometry.SmallestEnclosingBall.RandomizedIncrementalConstructionAlgorithms.Geometry.Diameter+Algorithms.Geometry.LineSegmentIntersection)Algorithms.Geometry.ConvexHull.GrahamScan(Algorithms.Geometry.LowerEnvelope.DualCH/Algorithms.Geometry.ConvexHull.DivideAndConquer(Algorithms.Geometry.RedBlueSeparator.RIC%Algorithms.Geometry.ClosestPair.NaiveData.PlaneGraph.AdjRepData.PlaneGraph.CoreData.PlaneGraph.IO#Data.Geometry.PlanarSubdivision.Raw%Data.Geometry.PlanarSubdivision.Basic%Data.Geometry.PlanarSubdivision.MergeData.Geometry.PlanarSubdivision"Data.Geometry.Arrangement.Internal.Algorithms.Geometry.PolygonTriangulation.Types5Algorithms.Geometry.PolygonTriangulation.MakeMonotone