Initial commit
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
public class AStarNode
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public double Heuristic { get; set; }
|
||||
public double TotalCost => Cost + Heuristic;
|
||||
public string? Name { get; set; }
|
||||
public AStarNode? Parent { get; set; }
|
||||
public List<AStarNode> NegativeNodes { get; set; } = [];
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is AStarNode other)
|
||||
return Id == other.Id;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
public record GlobalEdge
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MapId { get; set; }
|
||||
public Guid StartNodeId { get; set; }
|
||||
public Guid EndNodeId { 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,19 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
public class GlobalNode
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid MapId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public Orientation Orientation { get; set; }
|
||||
public override string ToString() => Name ?? typeof(GlobalNode).ToString();
|
||||
// Tính khoảng cách giữa 2 điểm
|
||||
public double DistanceTo(GlobalNode other)
|
||||
{
|
||||
double dx = X - other.X;
|
||||
double dy = Y - other.Y;
|
||||
return Math.Sqrt(dx * dx + dy * dy);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
/// <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(GlobalNode node, int axis, KDTreeNode? left = null, KDTreeNode? right = null)
|
||||
{
|
||||
/// <summary>
|
||||
/// The spatial node stored at this tree node.
|
||||
/// </summary>
|
||||
public GlobalNode 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;
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
public enum Orientation
|
||||
{
|
||||
FORWARD,
|
||||
BACKWARD,
|
||||
NONE
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
namespace RobotNet10.GlobalPathPlanner.Model;
|
||||
|
||||
public class SSEAStarNode
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public Orientation Orientation { get; set; }
|
||||
public double Cost { get; set; }
|
||||
public double Heuristic { get; set; }
|
||||
public double TotalCost => Cost + Heuristic;
|
||||
public string? Name { get; set; }
|
||||
public SSEAStarNode? Parent { get; set; }
|
||||
public List<SSEAStarNode> NegativeNodes { get; set; } = [];
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (obj is SSEAStarNode other)
|
||||
return Id == other.Id && Orientation == other.Orientation;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(Id, Orientation);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user