namespace RobotNet10.Common.Models; /// /// Represents a node in the KD-Tree structure. /// Immutable to prevent structural corruption. /// /// /// Initializes a new KD-Tree node. /// public class KDTreeNode(KDTreeData node, int axis, KDTreeNode? left = null, KDTreeNode? right = null) { /// /// The spatial node stored at this tree node. /// public KDTreeData Node { get; } = node ?? throw new ArgumentNullException(nameof(node)); /// /// Left child (contains points with smaller values along the split axis). /// public KDTreeNode? Left { get; } = left; /// /// Right child (contains points with larger values along the split axis). /// public KDTreeNode? Right { get; } = right; /// /// The axis used for splitting: 0 for X, 1 for Y. /// public int Axis { get; } = axis; } public record KDTreeData(string Id, double X, double Y);