Initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
namespace RobotNet10.Common.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a node in the KD-Tree structure.
|
||||
/// Immutable to prevent structural corruption.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Initializes a new KD-Tree node.
|
||||
/// </remarks>
|
||||
public class KDTreeNode(KDTreeData node, int axis, KDTreeNode? left = null, KDTreeNode? right = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// The spatial node stored at this tree node.
|
||||
/// </summary>
|
||||
public KDTreeData Node { get; } = node ?? throw new ArgumentNullException(nameof(node));
|
||||
|
||||
/// <summary>
|
||||
/// Left child (contains points with smaller values along the split axis).
|
||||
/// </summary>
|
||||
public KDTreeNode? Left { get; } = left;
|
||||
|
||||
/// <summary>
|
||||
/// Right child (contains points with larger values along the split axis).
|
||||
/// </summary>
|
||||
public KDTreeNode? Right { get; } = right;
|
||||
|
||||
/// <summary>
|
||||
/// The axis used for splitting: 0 for X, 1 for Y.
|
||||
/// </summary>
|
||||
public int Axis { get; } = axis;
|
||||
}
|
||||
|
||||
public record KDTreeData(string Id, double X, double Y);
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace RobotNet10.Common.Models;
|
||||
|
||||
public class SpaceEdge
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public double StartX { get; set; }
|
||||
public double StartY { get; set; }
|
||||
public double EndX { get; set; }
|
||||
public double EndY { get; set; }
|
||||
public int Degree { get; set; }
|
||||
public double ControlPoint1X { get; set; }
|
||||
public double ControlPoint1Y { get; set; }
|
||||
public double ControlPoint2X { get; set; }
|
||||
public double ControlPoint2Y { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace RobotNet10.Common.Models;
|
||||
|
||||
public record SpaceNode(double X, double Y)
|
||||
{
|
||||
public double DistanceTo(SpaceNode other)
|
||||
{
|
||||
double dx = X - other.X;
|
||||
double dy = Y - other.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user