Skip to main content

irox_geometry/
kdtree.rs

1// SPDX-License-Identifier: MIT
2// Copyright 2025 IROX Contributors
3//
4
5use crate::geometry::GeometryType;
6use irox_tools::FloatIsh;
7
8#[derive(Debug, Clone, PartialEq)]
9pub struct KDTree<PlaneType: FloatIsh, ValueType> {
10    root: KDNode<PlaneType, ValueType>,
11    size: usize,
12}
13#[derive(Debug, Clone, PartialEq)]
14pub enum KDNode<PlaneType: FloatIsh, ValueType> {
15    Empty,
16    Inner {
17        plane_value: PlaneType,
18        plane: KDAxis,
19        lesser_or_eq: Box<KDNode<PlaneType, ValueType>>,
20        greater: Box<KDNode<PlaneType, ValueType>>,
21        size: usize,
22        depth: usize,
23    },
24    Value {
25        value: ValueType,
26        geometry: GeometryType<PlaneType>,
27    },
28}
29impl<PlaneType: FloatIsh, ValueType> KDNode<PlaneType, ValueType> {
30    pub fn insert(&mut self) {}
31}
32#[derive(Debug, Copy, Clone, Eq, PartialEq)]
33pub enum KDAxis {
34    XAxis,
35    YAxis,
36}
37
38impl KDAxis {
39    #[must_use]
40    pub fn next(&self) -> Self {
41        match self {
42            KDAxis::XAxis => KDAxis::YAxis,
43            KDAxis::YAxis => KDAxis::XAxis,
44        }
45    }
46}