Computer Vector Graphics Math Library
Because reinventing the wheel is half the fun.
A path tracing scene using cvmath
. See pathtracing.rs.
🔍 What is this?
cvmath
is a lightweight, graphics-oriented math library written in Rust. It focuses on vector math and geometric primitives commonly used in computer graphics. It is not a general-purpose numerical library.
If you're building 2D/3D renderers, ray tracers, or similar tools and want something compact and to the point, this might be a good fit.
The API is lean, clear, and practical.
✨ Features Overview
All types are available at the crate root.
General Types
Vec2<T>
,Vec3<T>
,Vec4<T>
— 2D, 3D, and 4D vectorsBool2
,Bool3
,Bool4
— Boolean vector masksAngle<T>
— Angles in radiansComplex<T>
,Polar<T>
,Quat<T>
— Complex numbers, polar coordinates, and quaternions
Matrices and Transformations
Mat2<T>
,Mat3<T>
,Mat4<T>
— General-purpose matricesTransform2<T>
,Transform3<T>
— Affine transformations
Shapes and Geometry
Shapes are available in 2D and 3D variants.
Point2<T>
,Point3<T>
— 2D and 3D pointsBounds2<T>
,Bounds3<T>
— Axis-aligned bounding boxesPlane2<T>
,Plane3<T>
— Infinite planesCircle<T>
,Sphere<T>
— Defined by a center point and radiusLine2<T>
,Line3<T>
— Line segments defined by two pointsTriangle2<T>
,Triangle3<T>
— Triangles defined by three pointsShape2<T>
,Shape3<T>
— Generic shape enums for flexible composition
Ray Tracing
Types involved in ray casting and intersection:
Ray2<T>
,Ray3<T>
— Rays defined by origin, direction, and max distanceHit2<T>
,Hit3<T>
— Intersection results (distance, normal, index)Trace2<T>
,Trace3<T>
— Traits for types that support ray tracing
🔓 License
Licensed under the MIT License, see license.txt for details.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, shall be licensed as above, without any additional terms or conditions.