1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! A pure, standalone geometric kernel for CAD-grade curves and surfaces.
//!
//! `geomcore` provides parametric evaluation of elementary curves and
//! surfaces (lines, circles, ellipses, parabolas, hyperbolas, B-splines;
//! planes, cylinders, cones, spheres, tori, B-spline surfaces), rigid
//! transformations, and analytic curve-on-surface parametrization: computing
//! the exact 2D representation of a 3D curve in a surface's parameter space
//! wherever a closed form exists.
//!
//! # Namespace layout
//!
//! - The crate root re-exports the placement and value types shared by
//! everything else: [`Point3`]/[`Point2`], [`Vector3`]/[`Vector2`],
//! [`Axis3`]/[`Axis2`], [`Frame3`]/[`Frame2`], and [`Transform`].
//! - [`curves`] holds the 3D and 2D curve types ([`curves::Line3D`],
//! [`curves::Circle3D`], [`curves::Ellipse3D`], [`curves::Parabola3D`],
//! [`curves::Hyperbola3D`], [`curves::BSplineCurve3D`],
//! [`curves::Line2D`], [`curves::Circle2D`]), the [`curves::Curve3D`]/
//! [`curves::Curve2D`] enum adaptors, and the
//! [`curves::ParametricCurve3D`]/[`curves::ParametricCurve2D`] traits.
//! - [`surfaces`] holds the five elementary analytic surfaces
//! ([`surfaces::Plane`], [`surfaces::Cylinder`], [`surfaces::Cone`],
//! [`surfaces::Sphere`], [`surfaces::Torus`]) plus
//! [`surfaces::BSplineSurface`], the [`surfaces::Surface`] enum adaptor,
//! and the [`surfaces::ParametricSurface`] trait.
//!
//! # Quick start
//!
//! ```
//! use geomcore::{Cylinder, Point3, Vector3};
//! use geomcore::curves::Circle3D;
//!
//! // Evaluate a circle at a single parameter, and over a batch of parameters.
//! let circle = Circle3D::new(Point3::ORIGIN, Vector3::Z, 2.0).unwrap();
//! let point = circle.eval_point(std::f64::consts::PI / 4.0);
//! let points = circle.eval_points(&[0.0, 1.0, 2.0]);
//! assert_eq!(points[0], circle.eval_point(0.0));
//!
//! // Curve-on-surface parametrization: this circle is coaxial with the
//! // cylinder, so it has an exact 2D image, a horizontal line in (u, v).
//! let cylinder = Cylinder::new(Point3::ORIGIN, Vector3::Z, 2.0).unwrap();
//! let pcurve = circle.parametrize_on(&cylinder).unwrap();
//! # let _ = point;
//! ```
//!
//! # Extending the kernel
//!
//! New curve or surface types are added by implementing
//! [`curves::ParametricCurve3D`] (or [`curves::ParametricCurve2D`]) and
//! [`surfaces::ParametricSurface`] respectively, without touching the
//! existing dispatch code in [`curves::Curve3D`]/[`surfaces::Surface`].
pub
/// Internal analytic curve evaluation math.
pub
/// Public curve types: lines, conics, and B-spline curves.
/// Axis and frame placement types.
/// Points in 2D and 3D space.
/// Internal analytic surface evaluation math.
pub
/// Public surface types: planes, cylinders, cones, spheres, tori, and
/// B-spline surfaces.
/// Rigid and affine transformations.
/// Vectors in 2D and 3D space.
pub use ;
pub use ;
pub use ;
pub use ;
pub use Transform;
pub use ;