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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
//! # Wassily Geometry
//!
//! **Advanced geometric operations and spatial data structures for generative art.**
//! This crate provides sophisticated tools for working with curves, grids, spatial
//! data structures, and subdivision algorithms essential for creating complex
//! geometric patterns and algorithmic art.
//!
//! ## Key Features
//!
//! - **Parametric Curves**: Arc-length parameterized paths with interpolation and refinement
//! - **Spatial Data Structures**: Efficient quadtree implementation for point queries
//! - **Subdivision Algorithms**: Recursive quadrilateral and triangle subdivision with noise
//! - **Matrix Operations**: Generic matrix with convolution, multiplication, and linear algebra
//! - **Specialized Lines**: Artistic line effects including fade, sand, and stipple textures
//! - **Grid Systems**: Structured point grids with quadrilateral extraction
//!
//! ## Quick Start
//!
//! ```no_run
//! use wassily_geometry::*;
//! use wassily_core::points::pt;
//!
//! // Create a parametric curve
//! let points = vec![pt(0.0, 0.0), pt(100.0, 50.0), pt(200.0, 0.0)];
//! let curve = ParametricPath::new(points);
//! let midpoint = curve.point_at(0.5); // Get point at 50% along curve
//!
//! // Subdivision example
//! let quad = Quad::new(pt(0.0, 0.0), pt(0.0, 100.0), pt(100.0, 100.0), pt(100.0, 0.0));
//! let (left, right) = quad.split_v(0.3, 0.7);
//!
//! // Quadtree for spatial queries
//! let mut qtree = QNode::new(vec![pt(10.0, 10.0), pt(90.0, 90.0)], pt(0.0, 0.0), pt(100.0, 100.0));
//! let nearby = qtree.points_in_circle(pt(0.0, 0.0), pt(100.0, 100.0), pt(50.0, 50.0), 25.0);
//! ```
//!
//! ## Core Components
//!
//! ### Curves and Paths
//!
//! - **[`ParametricPath`]**: Arc-length parameterized curves with uniform sampling
//! - **[`curve`]**: Generate smooth curves from mathematical functions
//! - **[`refine`]**: Adaptive curve refinement for optimal approximation quality
//!
//! ### Spatial Data Structures
//!
//! - **[`QNode`]**: Quadtree for efficient spatial queries and nearest neighbor searches
//! - **[`Grid`]**: Structured point grids with quadrilateral mesh extraction
//!
//! ### Subdivision Algorithms
//!
//! - **[`Quad`]**: Quadrilateral subdivision with customizable split strategies
//! - **[`Tri`]**: Triangle subdivision for triangular mesh generation
//! - **[`warp_points`]**: Noise-based point perturbation for organic distortion
//!
//! ### Matrix and Linear Algebra
//!
//! - **[`Matrix`]**: Generic matrix operations including convolution and multiplication
//! - Zero-indexed, row-major storage with comprehensive operation support
//!
//! ### Artistic Line Effects
//!
//! - **[`FadeLine`]**: Lines with variable opacity subdivisions
//! - **[`SandLine`]**: Textured lines with grain-like appearance
//! - **[`DotLine`]**: Stippled lines with noise-based dot placement
//!
//! ## Applications
//!
//! - **Algorithmic Art**: Recursive subdivision patterns and fractal-like structures
//! - **Mesh Generation**: Quadrilateral and triangular mesh creation with organic distortion
//! - **Spatial Queries**: Efficient point location and nearest neighbor operations
//! - **Curve Manipulation**: Smooth interpolation and adaptive curve approximation
//! - **Pattern Generation**: Grid-based patterns with artistic line rendering
//!
//! ## Examples
//!
//! ### Recursive Subdivision
//!
//! ```no_run
//! use wassily_geometry::*;
//! use wassily_core::points::pt;
//!
//! // Create initial quad
//! let quad = Quad::new(pt(0.0, 0.0), pt(0.0, 100.0), pt(100.0, 100.0), pt(100.0, 0.0));
//! let mut quads = vec![quad];
//!
//! // Recursively subdivide
//! for _ in 0..5 {
//! quads = quad_divide_vec(
//! &quads,
//! |q| q.best_dir(), // Split along longest dimension
//! |_| (0.4, 0.6), // Split ratios
//! );
//! }
//! ```
//!
//! ### Parametric Curve Interpolation
//!
//! ```no_run
//! use wassily_geometry::*;
//! use wassily_core::points::pt;
//!
//! // Define control points
//! let points = vec![
//! pt(0.0, 50.0),
//! pt(25.0, 100.0),
//! pt(75.0, 0.0),
//! pt(100.0, 50.0),
//! ];
//!
//! let path = ParametricPath::new(points);
//!
//! // Sample points uniformly along curve length
//! let samples: Vec<_> = (0..=20)
//! .map(|i| path.point_at(i as f32 / 20.0))
//! .collect();
//! ```
//!
//! ### Spatial Indexing with Quadtree
//!
//! ```no_run
//! use wassily_geometry::*;
//! use wassily_core::points::pt;
//!
//! // Build quadtree with scattered points
//! let points = vec![
//! pt(10.0, 10.0), pt(25.0, 80.0), pt(90.0, 30.0),
//! pt(45.0, 45.0), pt(70.0, 15.0), pt(30.0, 90.0),
//! ];
//!
//! let qtree = QNode::new(points, pt(0.0, 0.0), pt(100.0, 100.0));
//!
//! // Find all points within radius of query point
//! let query_center = pt(50.0, 50.0);
//! let radius = 30.0;
//! let nearby = qtree.points_in_circle(
//! pt(0.0, 0.0), pt(100.0, 100.0),
//! query_center, radius
//! );
//! ```
// Re-export key types and functions for convenience
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;