úÎXÍS¯     None98!KCSG solid is a recursive composition of primitive objects or other solids.^Half-space defined by a unit outward normal and a distance of boundary plane from the origin. .Sphere defined by a center point and a radius.!^Infinite circular cylinder defined by a normalized axis vector, a point on axis and a radius."uCone defined by an inward axis direction, a vertex and a cosine to the angle h between the axis and the generatrix.€Additionally, a transformation matrix $n * n - cos^2 h$, tangent of angle and odelta are stored for intersection calculations.pTrace of a ray/line on a solid is a list of segments corresponding to the portions of the ray inside the solid. } O - ray -- > -- > +------------ A segment of ray inside a solid.½A point at which a ray intersects a surface, given as a distance from the ray's initial point and an outward normal to the surface at the hit point. If hit is in infinity, then normal is #l. If the hit occures on the same line but precedes the initial point of the ray, the distance is negative.™Note that this datatype is strict only on first argument: we do not compare normals when combining traces and thus do not force calculation of normals. A ray described by the equation p(t) = p_0 + v * t with an initial point p_0 and a direction v . Substituting a specific time t'. in the equation yields a position of a point p(t')% on the ray. For negative values of t'', position precedes the initial point.We use $ as a simple replacement for (Double, Double, Double). $… implements a contiguous storage scheme for Unboxed and Storable vectors which shows better performance. Compile this package with triples0 flag and run benchmarks to see the difference.%IEEE positive infinity.&Negative infinity.'Hit in negative infinity.(Hit in positive infinity. wA half-space defined by an arbitary point on the boundary plane and an outward normal (not necessarily a unit vector). 0A sphere defined by a center point and a radius. TA rectangular cuboid with faces parallel to axes, defined by two opposite vertices. SAn infinite circular cylinder defined by two arbitary points on axis and a radius. [A finite right circular cylinder defined by two points on its top and bottom and a radius.ŸAn infinite right circular cone defined by an outward axis vector, an apex point and an angle between the generatrix and the axis (in degrees, less than 90).ŸA conical frustum defined by two points on its axis with radii at that points. One of radii may be zero (in which case one of frustum ends will be the apex).Intersection of two solids.Union of two solids.(Complement to a solid (normals flipped).Subtract a solid from another.Trace of a ray on a solid.5Find the next point where a ray hits a solid, if any.0Here we consider only future intersections: the B is guaranteed to have non-negative distance (unlike when using ).SThis means that if the ray starts inside the solid the only way to tell that from N result is to compare it's direction and the surface normal at the hit point.)Union of two traces.*Intersection of two traces.+(Complement to a trace (normals flipped).)True if the point is in inside the solid.,FMove point by velocity vector for given time and return new position.-Solve quadratic equation ax^2 + bx + c = 0.2If less than two roots exist, Nothing is returned.,Current position. Velocity. Time step.-abc.$./0123456789:;<=>?@ABC     !"DEFNoneS8GParser with a lookup table.H1Transformer which adds a lookup table to a monad.I!Add an entry to the lookup table.JLookup entry in the table.K.Read three comma-separated doubles into point. /<triple> ::= <double> ',' <double> ',' <double>L-Read variable name or fail if it's a keyword.MJLook up a solid in the table by its name or fail if it's not defined yet.NGParse binary operation on two bodies with given composition operators.Note that due to the way N and OJ combinators recurse into each other multi-solid composition chains are right-associativeš. However, this also means that if we keep simpler solids on the left then ray casting routines will have a chance to work faster and terminate earlier.PCRead a stamement which adds a new solid entry to the lookup table. 3<statement> ::= 'solid' <varname> '=' <solid> ';'OjExpression is either a primitive, a reference to previously defined solid or an operation on expressions. O<solid> ::= <union> | <intersection> | <complement> | <primitive> | <reference>Q5Used to terminate left branch of binary compositions. 0<uncomposed-solid> ::= <primitive> | <reference>RTop-level object declaration. <tlo> ::= 'tlo' <solid> ';'S.Read one-line comment starting with hash sign.T_Read sequence of statements which define solids, and finally read top level object definition. A<geoFile> ::= <statement> <geoFile> | <comment> <geoFile> | <tlo>KRead solid definition. If parsing fails, return error message as a string.WRead solid definition from a file. If parsing fails, return error message as a string.SafeSˆUVWXYZ[\]      !"#$%&'()*+,-./0123()*(45(46(47(48(49(4:(4;(4<(4=(4>(4?(4@(4A(4B(4C(4D(4E(4F(4G(4H(4IJKLMNOPQRSTUVWXYZ[\]^_`abccsg-0.1-Ev5gI0LR61nCL0tDj3ugywData.CSGData.CSG.Parser Paths_csgSolidTrace HitSegmentHitPointRayPointVec3planespherecuboidcylindercylinderFrustumcone coneFrustum intersectunite complementsubtracttracecastinside $fOrdHitPoint$fArbitrarySolid $fEqHitPoint$fShowHitPoint $fEqSolid $fShowSolid parseGeometryparseGeometryFilePlaneSphereCylinderCone#strict-0.3.2-1XGU2LPrqRE7Qw1PnSNhY5Data.Strict.MaybeNothing*simple-vec3-0.4.0.1-AVhtYvy4Y4ECbu5IyDctbw Data.Vec3CVec3 infinityP infinityNhitNhitP uniteTracesintersectTracescomplementTracemoveBysolveqData.Vec3.Class><zipWith<+> normalizeoriginfromXYZtoXYZ<->.^.*normdistanceinvertfromRowstoRowsdotMmxvdiagvxvaddMTVec3Union Intersection Complement CSGParserTableTaddEntrygetEntrytriplevarNamereadNamebinarysolid statementuncomposedSolidtopLevelcommentgeoFileversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDir getSysconfDirgetDataFileName