+i$ly      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxA modified version of y and Control.Applicative.Applicative that adds the z L constraint on the result. You are unlikely to need to use this class much  directly. Some vectors have y and Control.Applicative.Applicative instances anyway. Like { , but with a z constraint. Like Control.Applicative.liftA2 , but with a z constraint. Like !, but can only be used if you won't change the magnitude: Like Control.Applicative.pure (or | ) but with a z constraint. MThis class is implemented by all 3D vectors. To get the X and Y components,  use  and   from . 7This class is implemented by all 2D and 3D vectors, so  gets the X co-ordinate  of both 2D and 3D vectors.  .The class that is implemented by all vectors. 'Minimal implementation: fromComponents <Gets the components of the vector, in the order x, y (, z). LRe-constructs a vector from the list of coordinates. If there are too few, R the rest will be filled with zeroes. If there are too many, the latter ones are  ignored. CGets the magnitude squared of the vector. This should be fast for  repeated calls on Data.SG.Geometry.TwoDim.Rel2' and  Data.SG.Geometry.ThreeDim.Rel3', which cache this value. -Computes the dot product of the two vectors. KAn isomorphism amongst vectors. Allows you to convert between two vectors P that have the same dimensions. You will notice that all the instances reflect  this.  The origin/<all-zero vector (can be used with any vector type you like) (Gets the magnitude of the given vector. LScales the vector so that it has length 1. Note that due to floating-point N inaccuracies and so on, mag (unitVector v) will not necessarily equal 1, but M it should be very close. If an all-zero vector is passed, the same will be  returned. 1This function should be very fast when called on  Data.SG.Geometry.TwoDim.Rel2' and Data.SG.Geometry.ThreeDim.Rel3'; @ vectors that are already unit vectors (no processing is done). IGets the average vector of all the given vectors. Essentially it is the / sum of the vectors, divided by the length, so #averageVec [Point2 (-3, 0), Point2  (5,0)] will give  Point2 (1,0). If the list is empty, the  all-zero vector is returned. DLike averageVec composed with unitVector -- gets the average of the U vectors in the list, and normalises the length. If the list is empty, the all-zero H vector is returned (which is therefore not a unit vector). Similarly, V if the average of all the vectors is all-zero, the all-zero vector will be returned. JWorks out if the two vectors are in the same direction (to within a small  tolerance). LGives back the vector (first parameter), translated onto given axis (second 6 parameter). Note that the scale is always distance, not related to the size  of the axis vector. KProjects the first parameter onto the given axes (X, Y), returning a point  in terms of the new axes. KGives back the point (first parameter), translated onto given axis (second 6 parameter). Note that the scale is always distance, not related to the size  of the axis vector. SProjects the point (first parameter) onto the given axes (X, Y), returning a point  in terms of the new axes. +Works out the distance between two points.         GA pair of (position vector, direction vector) to be used as a 3D line. GA pair of (position vector, direction vector) to be used as a 2D line.  #A quad, which acts as a 4D vector. !"%A triple, which acts as a 3D vector. #$#A pair, which acts as a 2D vector. %  !"#$% $%"# !  !!"##$%%&KA geometry system, parameterised over points, relative (free) vectors, and S lines. There are separate instances for two dimensions and for three dimensions. R Each pair of type-class parameters is uniquely determined by the other parameter D (i.e. by the dimensionality, and which vector type you are using). 1Minimal implementation: everything but scaleRel. '5Scales a relative (free) vector by the given amount. (0Adds a relative (free) vector to a given point. )&Determines the relative (free) vector to the first parameter from the  second parameter. So: 5 Point2 (1,8) `fromPt` Point2 (3,4) == Point2 (-2,3) *NGiven a line, converts it back into its point and relative vector. It should  always be the case that uncurry makeLine . getLineVecs is the identity function. +HGiven a point and relative vector, creates a line. It should always be  the case that uncurry makeLine . getLineVecs is the identity function. ,>Adds the negation of the relative (free) vector to the point. -The flipped version of ). .Gets the line from the first point, to the second point. /The flipped version of .. 0)Gets the point at the start of the line. 1'Gets the direction vector of the line. 2'Gets the point at the end of the line. 3RAlters the line to the given length, but with the same start point and direction. 4Given a multiple of the direction vector (this is not distance unless @ the direction vector is a unit vector), calculates that point. 5VChecks if the given point is on the given line (to within a small epsilon-tolerance). S If it is, gives back the distance along the line (as a multiple of its direction S vector) to the point in a Just wrapper. If the point is not on the line, Nothing  is returned. 6VChecks if the given point is on the given line (to within a small epsilon-tolerance). 7KFinds the nearest point on the line to the given point, and gives back its M distance along the line (as a multiple of the direction vector). Since the M nearest distance will be at a right-angle to the point, this is the same as % projecting the point onto the line. 8KFinds the nearest point on the line to the given point, and gives back the  point. 9RGives the distance along the line (2D or 3D) at a given X value. Returns Nothing P if the line is parallel to the YZ plane (in 2D, if the X component of the line R is zero). The value returned is a multiple of the direction vector of the line, S which will only be the same as distance if the direction vector is a unit vector. :RGives the distance along the line (2D or 3D) at a given Y value. Returns Nothing P if the line is parallel to the XZ plane (in 2D, if the Y component of the line R is zero). The value returned is a multiple of the direction vector of the line, S which will only be the same as distance if the direction vector is a unit vector. ;JGives the distance along the 3D line at a given Z value. Returns Nothing K if the line is parallel to the XY plane. The value returned is a multiple E of the direction vector of the line, which will only be the same as 4 distance if the direction vector is a unit vector. <;pointAtX (and the Y and Z equivalents) are wrappers around 9 (and H similar) that give back the point rather than distance along the line. =;pointAtX (and the Y and Z equivalents) are wrappers around 9 (and H similar) that give back the point rather than distance along the line. >&'()*+,-./0123456789:;<=>&'()*+,-./0123456789:;<=>&'()*+'()*+,-./0123456789:;<=>?EA line in 2D space. A line is a point, and a free vector indicating K direction. A line may be treated by a function as either finite (taking L the magnitude of the free vector as the length) or infinite (ignoring the & magnitude of the direction vector). @ABCSA relative vector (free vector) in 2D space. The pair are the x and y components,  and the last item is the squared magnitude of the vector, which is stored B with it to speed up various operations. It is suggested you use G N to create one of these, unless the square magnitude is easily apparent, e.g. Rel2  (0, 2) 4 DEA point in 2D space. FGConstructs a Rel2' vector. HGets the angle, in radians/, anti-clockwise from the x-axis. If you pass 5 the all-zero vector, the return value will be zero. IOGets the vector perpendicular to the given 2D vector. If you pass it a vector P that is in a clockwise direction around a polygon, the result will always face  away from the polygon. JJReflects the first direction vector against the given surface normal. The K resulting direction vector should have the same magnitude as the original  first parameter. An example: H makeRel2 (-3, -4) `reflectAgainst2` makeRel2 (0,1) == makeRel2 (-3, 4) KKReflects the first direction vector against the given surface normal. The Q resulting direction vector should have the same magnitude as the original first  parameter. JThe reflection is not performed if the given vector points along the same M direction as the normal, that is: if once projected onto the normal vector, E the component is positive, the original first parameter is returned  unmodified. Examples: P makeRel2 (-3, -4) `reflectAgainstIfNeeded2` makeRel2 (0,1) == makeRel2 (-3, 4) O makeRel2 (-3, 4) `reflectAgainstIfNeeded2` makeRel2 (0,1) == makeRel2 (-3, 4) LIGiven two 2D lines, finds out their intersection. The first part of the L result pair is how much to multiply the direction vector of the first line C by (and add it to the start point of the first line) to reach the R intersection, and the second part is the corresponding item for the second line.  So given #Just (a, b) = intersectLines2 la lb, it should be the case (minus $ some possible precision loss) that  alongLine a la == alongLine b lb . If the * lines are parallel, Nothing is returned. NNote that this function assumes the lines are infinite. If you want to check P for the intersection of two finite lines, check if the two parts of the result . pair are both in the range 0 to 1 inclusive. MOFinds all the intersections between a line from the first list and a line from O the second list, and how far along that is each line. That is, this is a bit P like mapMaybe composed with intersectLines2 on all pairings of a line from the - first list and a line from the second list. NOGiven a line, and a circle (defined by a point and a radius), finds the points  of intersection. LIf the line does not intersect the circle, Nothing is returned. If they do M intersect, two values are returned that are distances along the line. That  is, given %Just (a, b) = intersectLineCircle l c!, the two points of intersection  are (alongLine l a, alongLine l b). MThe ordering of the two items in the pair is arbitrary, and if the line is a 5 tangent to the circle, the values will be the same. OLike >1, but returns a 2D vector instead of a 3D vector }Multiplication doesn'$t make much sense, but the rest do! ?@ABCDEFGHIJKLMNOEFCDG?@ABHIJKLMNO?@AB@ABCDDEFFGHIJKLMNO PDA line in 3D space. A line is a point and a free vector indicating K direction. A line may be treated by a function as either finite (taking L the magnitude of the free vector as the length) or infinite (ignoring the & magnitude of the direction vector). QRSTTA relative vector (free vector) in 3D space. The triple is the x, y, z components,  and the last item is the squared magnitude of the vector, which is stored B with it to speed up various operations. It is suggested you use X G to create one of these, unless the magnitude is easily apparent, e.g. Rel3  (0, 1, 1) 2 UVA point in 3D space. WXConstructs a Rel3' vector PQRSTUVWX VWTUXPQRS PQRSQRSTUUVWWXY'The class that all matrices belong to. Z)Gives back the matrix as a list of rows. [FCreates a matrix from a list of rows. Any missing entries are filled K in with the relevant entries from the identity matrix, hence the identity  matrix is equivalent to fromMatrixComponents []. \Transposes a matrix ];A 4x4 matrix. Primarily useful via its instances, such as y, z,  and Y. ^;A 3x3 matrix. Primarily useful via its instances, such as y, z,  and Y. _;A 2x2 matrix. Primarily useful via its instances, such as y, z,  and Y. `8A square matrix. You will almost certainly want to use _ and similar O instead of this directly. It does have a variety of useful instances though,  especially y, z and Y. OIts definition is based on a square matrix being, for example, a pair of pairs  or a triple of triples. a~bThe identity matrix. cAMatrix multiplication. There is no requirement that the size of , the matrix matches the size of the vector: M If the vector is too small for the matrix (e.g. multiplying a 4x4 matrix by ? a 3x3 vector), 1 will be used for the missing vector entries. M If the matrix is too small for the vector (e.g. multiplying a 2x2 matrix by K a 3x3 vector), the other components of the vector will be left untouched. NThis allows you to do tricks such as multiplying a 4x4 matrix by a 3D vector, 7 and doing translation (a standard 3D graphics trick). dJMatrix multiplication where the size of the vector matches the dimensions I of the matrix. The complicated type just means that this function will M work for any combination of matrix types and vectors where the width of the F square matrix is the same as the number of dimensions in the vector. eGiven an angle in radians0, produces a matrix that rotates anti-clockwise O by that angle around the Z axis. Note that this can be used to produce a 2x2 H (in which case it is a rotation around the origin), 3x3 or 4x4 matrix. fGiven an angle in radians0, produces a matrix that rotates anti-clockwise P by that angle around the X axis. Note that this can be used to produce a 2x2, M 3x3 or 4x4 matrix, but if you produce a 2x2 matrix, odd things will happen! gGiven an angle in radians0, produces a matrix that rotates anti-clockwise P by that angle around the Y axis. Note that this can be used to produce a 2x2, M 3x3 or 4x4 matrix, but if you produce a 2x2 matrix, odd things will happen! hJGiven a 2D relative vector, produces a matrix that will translate by that A much (when you multiply a 2D point with it using multMatrixGen) iJGiven a 3D relative vector, produces a matrix that will translate by that A much (when you multiply a 3D point with it using multMatrixGen) YZ[\]^_`abcdefghi_^]`aYZ[\bdchifgeYZ[\Z[\]^_`aabcdefghijKA type for simple 2D convex shapes. It is expected that you will define a ) synonym in your own application such as type Shape = Shape' Double, hence  the funny name. kHA polygon with a centre, and a list of points. The points are relative M vectors from the centre of the polygon, and are expected to be in clockwise F order. For example, the triangle with corners (1,1) (3,3) and (3,1)  could be ?Polygon (Point2 (2.5, 1.5)) [Rel2 (-1.5,-0.5), Rel2 (0.5,1.5),  Rel2 (-1.5, 1.5)]. DNote that whereabouts the centre is inside the polygon is up to you  (it does not  have to be+ the geometric average of the points), but H it should at least be inside the polygon, or else some algorithms will  behave strangely with it. EThe list of points should have at least 3 points in it, or else some # algorithms will behave strangely. CIf your points are not in clockwise order (with the X-Y axes being H how they are in graphs, not on screens), funny things will happen with  the collision detection. lm%A circle with a centre and a radius. noAA rectangle with a centre, and a width (distance from the centre D to the left or right side of the rectangle) and a height (distance E from the centre to the top or bottom side of the rectangle. So the + rectangle with corners (1,1) and (3,2) is Rectangle (Point2 (2,1.5))  (1, 0.5):. Technically a rectangle is a polygon, of course, but a O rectangle (which is axis-aligned) can be processed faster by most algorithms. pqr8Moves a shape by a given vector (by moving the centre). sGiven an angle in radians7, rotates the shape by that angle in an anti-clockwise U direction. A circle will remain untouched, a polygon will have its points rotated, Z and a rectangle will become a polygon and get rotated (even if you pass 0 as the angle). tKScales the size of the shape (for all edges, from the centre) by the given  factor. uGGives back the bounding box of a shape in terms of the minimum X-Y and . the maximum X-Y corners of the bounding box. vGGiven a line and a shape, finds all possible intersections of the line K with the shape. Since the shapes are convex, continuous 2D shapes, there I will either be no intersections or two (which could be the same point). M The returned value is distance along the line in multiples of the direction . vector (the return value is the same idea as N). wDChecks for overlap between the two shapes. If they do not collide, M returns Nothing. If they do collide, gives back suggested angles away from K each other. These are not necessarily the shortest direction to separate O the two shapes, but should be decent for doing collision resolution (by using 0 them as surface normals, or push-away vectors) KThe first vector returned is the direction in which the first shape should I head (or the surface normal to bounce the first shape off), whereas the J second vector returned is the direction in which the second shape should > head (or the surface normal to bounce the second shape off). OThis function includes an initial quick test, followed by a more detailed test  if necessary. (A quick test for possible intersection. PIf it returns False, there is definitely no overlap. If it returns True, there R might be some overlap. For two circles, radiuses are checked (and the answer is Q always accurate), for any other combination of shapes it checks bounding boxes. LCollects a list of (unit-vector) axes perpendicular to all the edges of the A polygon, pointed outwards. The list will be empty for circles. LGiven a shape, gets a list of relative vectors from the centre of the shape R to the points of the shape. For polygons, this is the points list (unmodified). O For rectangles, it will be vectors to the four corners, and for circles, the  list will be empty. xFGiven a shape, gets a list of points that make up the vertices of the / shape. For circles, this list will be empty. MGets a list of lines representing each side of the shape (headed clockwise). ' For circles, the list will be empty. jklmnopqrstuvwxjomkpqpnplrstxuwvj omkpqpnplklmnopqrstuvwxy  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwx      !"#$%%&&''(())*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcddefghijklmnopqrstuvwxyz{|}~||}|SG-1.0Data.SG.VectorData.SG.Vector.BasicData.SG.GeometryData.SG.Geometry.TwoDimData.SG.Geometry.ThreeDimData.SG.Matrix Data.SG.ShapeData.SG VectorNumfmapNum1fmapNum2 fmapNum1inv simpleVecCoord3getZCoord2getXgetYCoord getComponentsfromComponentsmagSq dotProductIsomorphicVectorsisooriginmag unitVector averageVecaverageUnitVec sameDirection projectOnto projectOnto2projectPointOntoprojectPointOnto2distFrom LineTripleLinePairQuadTriplePairGeometryscaleRelplusDirfromPt getLineVecsmakeLineminusDirtoPtlineTolineFrom getLineStart getLineDir getLineEnd makeLength alongLine distAlongLineisOnLinenearestDistOnLinenearestPointOnLinevalueAtXvalueAtYvalueAtZpointAtXpointAtYpointAtZLine2'Line2 getLineStart2 getLineDir2Rel2'Rel2Point2'Point2makeRel2toAngleperpendicular2reflectAgainst2reflectAgainstIfNeeded2intersectLines2findAllIntersections2intersectLineCircle point2AtZLine3'Line3 getLineStart3 getLineDir3Rel3'Rel3Point3'Point3makeRel3MatrixmatrixComponentsfromMatrixComponents transpose Matrix44' Matrix33' Matrix22' SquareMatrixidentityMatrix multMatrixGen multMatrix rotateZaxis rotateXaxis rotateYaxis translate2D translate3DShape'Polygon polyPointsCirclecircSize Rectangle shapeCentrerectSize moveShape rotateShape scaleShape boundingBoxintersectLineShapeoverlap shapePointsbaseGHC.BaseFunctorGHC.NumNumfmap fromInteger $fNumRel2'fromListpts twoFromListbetweenpossibleOverlap projectShape pairsInLoop collectAxes polygonPoints polygonLinesdetailedOverlap