cadcore-math 0.1.5

Fundamental math primitives for the cadcore CAD kernel - Point3, Vec3, Mat3, Frame3
Documentation

cadcore-math

crates.io License: PolyForm Noncommercial 1.0.0 Rust

Fundamental math primitives for the cadcore CAD kernel.

Zero external dependencies. Everything in cadcore is built on top of this crate.


Types

Type Description
Point3 Location in 3-D space (mm)
Vec3 Free vector — direction + magnitude
UnitVec3 Unit-length vector, enforced at construction
Mat3 3×3 column-major matrix (rotation, linear maps)
Frame3 Right-handed orthonormal frame (origin + 3 axes)
Transform3 Rigid-body transform: rotation + translation
Interval Closed real interval [lo, hi]

Constants: EPS, PI, TAU.


Usage

[dependencies]
cadcore-math = "0.1"
use cadcore_math::{Point3, Vec3, UnitVec3, Mat3, Frame3};

// Build a right-handed frame from an origin and a Z axis
let origin = Point3::new(1.0, 2.0, 0.0);
let axis   = UnitVec3::try_from_vec(Vec3::new(0.0, 0.0, 1.0)).unwrap();
let frame  = Frame3::from_origin_z(origin, axis);

// Vector arithmetic
let a = Vec3::new(1.0, 0.0, 0.0);
let b = Vec3::new(0.0, 1.0, 0.0);
let c = a.cross(b);       // (0, 0, 1)
let d = a.dot(b);         // 0.0

// 3×3 rotation matrix
let rot = Mat3::rotation_z(std::f64::consts::FRAC_PI_2);  // 90° around Z
let v   = rot * Vec3::new(1.0, 0.0, 0.0);                 // (0, 1, 0)

// Interval utilities
use cadcore_math::Interval;
let i = Interval::new(0.0, 10.0);
assert!(i.contains(5.0));
let (lo, hi) = i.lerp_pair(0.25, 0.75);  // 2.5, 7.5

Part of cadcore

This crate is a building block. If you need the full kernel (sweep, STEP export), use the cadcore facade instead:

[dependencies]
cadcore = "0.1"

License

PolyForm Noncommercial License 1.0.0

Free for research, education, and non-commercial use. Commercial licensing: dmytroyatskovskiy@gmail.com