csg
Use triples of Doubles to represent vectors (slower with vector library arrays)
Use -f <flag> to enable a flag, or -f -<flag> to disable that flag. More info
For package maintainers and hackage trustees
CSG is a constructive solid geometry library with support
for ray casting. CSG allows you to define a complex solid as a
composition of primitives. It also provides functions to perform ray
casting (find an intersection of a ray and the defined solid) or test
whether a point belongs to the solid (for Monte Carlo volume
calculation).
Please consult the Hackage page for csg
for full documentation.
By default csg is built using CVec3 from simple-vec3 to
represent vectors and points, which according to benchmarks shows
better performance with Unboxed and Storable vectors. Build csg with
triples flag to use (Double, Double, Double) instead which may be
a more convenient programmatic interface that needs no
fromXYZ/toXYZ.
See alternatives too.
The package also includes csg-raycaster executable, which is a
simple interactive GUI for the ray casting algorithm.
csg-raycaster takes a geometry defintion file as input. See
cube.geo:
Please consult the Hackage page for Data.CSG.Parser for
full format specification.
csg-raycaster may be run as
Run as csg-raycaster --help to see all options.
When run without a file argument, csg-raycaster will try to display
an arbitrary CSG solid.
In the GUI window the following controls are supported:
| Input | Function |
|---------------------------|--------------------------------------|
| Left mouse button + drag | Rotate |
| Right mouse button + drag | Pan |
| Mouse wheel up | Zoom in |
| Mouse wheel down | Zoom out |
| r | Reset zoom level and camera position |
csg library performs no surface interpolation when doing ray casting.
Instead, we only solve ray-surface intersection equation numerically.
The library was written with Repa/vector compatibility and performance
in mind.
There're other Haskell libraries for CSG:
GlomeTrace:
Has more ray tracing-specific features, such as light sources,
different textures and materials.
Unlike csg, has no tests or benchmarks.
In csg solids use the same type as opposed to different types
with an existential box in GlomeTrace.
implicit:
Offers a much richer operation set.
Uses function representation for CSG solids.
If implicit had ray-casting support in early 2012 then I
probably wouldn't write csg.
mecha:
Only provides types and functions to define solids and export
definitions to external formats.
No support for ray casting.