Core 1.0
CoreLib

CoreLib is a C++17 library of geometric, mathematical and graphics primitives, designed as the foundation of graphics, procedural modeling and simulation applications. It is built on top of Qt (QtCore containers, QtGui for drawing and images).

Contents

Core math classes.Vectors, matrices, quaternions, polynomials (quadric to nonic), complex numbers, interval and affine arithmetic, random numbers.
Core geometric classesCore 3D primitives: Box, Sphere, Plane, Triangle, Segment, Cylinder, Cone, Torus, Capsule, Axis, Frame, Ray, curves.
Extended geometric classesPolyhedra and compound solids: tetrahedra, octahedra, icosahedra, Cuboid, Pyramid, Mesh, Polygon, Sector, parametric surfaces.
Planar geometric classes2D counterparts and planar-only shapes: Box2, Disc2, Circle2, Segment2, Triangle2, Convex2, Polygon2, Ellipse2, Frame2, planar curves.
Geometric structuresRegular grids and fields: Array2, ScalarField2, VectorField2, ScalarField, Voxel, analytic fields.
Color classesColor, palettes and color spaces (HSL, Lab, XYZ).
Generic core classes.System utilities: hashing, CPU information.

Beyond the groups, the library also provides procedural noise (Perlin, simplex, Gabor, phasor, worm, Voronoi), Eden and DLA growth models, and thin wrappers around OpenGL shaders and textures.

Conventions

  • Vectors: a * b is the dot product and a / b the cross product (the scalar cross product x1 y2 - x2 y1 for Vector2).
  • Distances: member functions R() return the squared distance to the shape (null inside), Signed() the signed distance (negative inside), and Normal() the vector from the nearest point of the shape to the argument (null inside). See Frequently Asked Questions.
  • Polygons and convex shapes are stored counter-clockwise.
  • Transformations are applied in place with Translate(), Rotate(), Scale() and Transform(); Symmetry() mirrors a point.
  • Classes are kept small: derived quantities (squared radius, center, diagonal) are computed on the fly.

Getting started

Box box(Vector(0.0), Vector(1.0)); // Unit box
double d = box.R(Vector(2.0, 0.5, 0.5)); // Squared distance from a point to the box
Ray ray(Vector(-1.0, 0.5, 0.5), Vector(1.0, 0.0, 0.0));
double t;
if (box.Intersect(ray, t)) // Intersection depth
{
Vector p = ray(t);
}
An axis aligned box.
Definition box.h:22
A ray characterized by its origin an unit direction vector.
Definition ray.h:14
Vectors in three dimensions.
Definition evector.h:13
Vector()
Empty.
Definition evector.h:18

License

Copyright © by Eric Galin. No representations are made about the suitability of this software for any purpose. It is provided as is without express or implied warranty.