namespace RobotNet10.RobotApp.Detection;
///
/// Represents a 2D point with additional laser scan metadata
///
public class Point(double x, double y, double range, double alpha)
{
///
/// X coordinate in meters
///
public double X { get; set; } = x;
///
/// Y coordinate in meters
///
public double Y { get; set; } = y;
///
/// Range of point from Lidar sensor in meters
///
public double Range { get; set; } = range;
///
/// Angle of laser beam to the point in radians
///
public double Alpha { get; set; } = alpha;
///
/// Cluster ID assigned by clustering algorithm (-1 if unassigned)
///
public int Cluster { get; set; } = -1;
///
/// Reachability distance for OPTICS algorithm
///
public double ReachabilityDistance { get; set; } = double.MaxValue;
///
/// Whether this point has been processed by the algorithm
///
public bool Processed { get; set; } = false;
}
///
/// Simple 2D point structure for cluster results
///
public struct Point2D(double x, double y) : IEquatable, IComparable
{
///
/// X coordinate in meters
///
public double X { get; set; } = x;
///
/// Y coordinate in meters
///
public double Y { get; set; } = y;
public readonly bool Equals(Point2D other)
{
return Math.Abs(X - other.X) < 3e-3 && Math.Abs(Y - other.Y) < 3e-3;
}
public override readonly bool Equals(object? obj)
{
return obj is Point2D other && Equals(other);
}
public override readonly int GetHashCode()
{
return HashCode.Combine(X, Y);
}
public readonly int CompareTo(Point2D other)
{
if (!X.Equals(other.X))
return X.CompareTo(other.X);
return Y.CompareTo(other.Y);
}
public static bool operator ==(Point2D left, Point2D right)
{
return left.Equals(right);
}
public static bool operator !=(Point2D left, Point2D right)
{
return !left.Equals(right);
}
}