/// <summary> /// Detect and return a list of Clusters point in pointList /// </summary> /// <param name="pointsList"></param> /// <param name="thresold"></param> /// <param name="mininum_amount_of_points"></param> /// <returns></returns> public static List <ClusterObjects> DetectClusterOfPoint(List <PolarPointRssiExtended> pointsList, double thresold, int mininum_amount_of_points = 5) { /// ABD Stand for Adaptative breakpoint Detection List <ClusterObjects> listOfClusters = new List <ClusterObjects>(); ClusterObjects cluster = new ClusterObjects(); int i; for (i = 1; i < pointsList.Count - 1; i++) { PolarPointRssiExtended point_n_minus_1 = pointsList[i - 1]; PolarPointRssiExtended point_n_plus_1 = pointsList[i + 1]; PolarPointRssiExtended point_n = pointsList[i]; //double dist_n_minus_1 = point_n_minus_1.Distance; //double delta_theta = Math.Abs(point_n_minus_1.Angle - point_n.Angle); //double lambda = point_n_plus_1.Angle - point_n_minus_1.Angle; double ABD_Thresold = thresold; // dist_n_minus_1 * (Math.Sin(delta_theta) / Math.Sin(lambda - delta_theta)); double distance_between_point = Toolbox.Distance(point_n, point_n_minus_1); if (distance_between_point < ABD_Thresold) { cluster.points.Add(point_n); } else { if (Toolbox.Distance(point_n_plus_1, point_n_minus_1) <= 2 * thresold) { //cluster.points.Add(point_n); } else { if (cluster.points.Count() > mininum_amount_of_points) { listOfClusters.Add(cluster); } cluster = new ClusterObjects(); } } } if (cluster.points.Count() > mininum_amount_of_points) { listOfClusters.Add(cluster); } return(listOfClusters); }
public static List <SegmentExtended> ExtractSegmentsFromCurvature(List <PolarPointRssiExtended> ptList, List <PolarCourbure> curvatureList, double seuilCourbure = 1.01, double minimum_distance = 0.3) { List <SegmentExtended> segmentList = new List <SegmentExtended>(); bool segmentEnCours = false; PolarPointRssiExtended ptDebutSegmentCourant = new PolarPointRssiExtended(new PolarPointRssi(), 1, Color.White); PolarPointRssiExtended ptFinSegmentCourant = new PolarPointRssiExtended(new PolarPointRssi(), 1, Color.White); for (int i = 0; i < curvatureList.Count; i++) { if (curvatureList[i].Courbure < seuilCourbure && Toolbox.Distance(ptList[i].Pt, ptList[Math.Max(0, i - 1)].Pt) < 3) { if (segmentEnCours == false) { //On a un nouveau segment ptDebutSegmentCourant = ptList[i]; } //linePoints.Add(ptList[i]); segmentEnCours = true; } else { if (segmentEnCours == true) { //On a une fin de segment ptFinSegmentCourant = ptList[i - 1]; PointD segment_start_point = new PointD(ptDebutSegmentCourant.Pt.Distance * Math.Cos(ptDebutSegmentCourant.Pt.Angle), ptDebutSegmentCourant.Pt.Distance * Math.Sin(ptDebutSegmentCourant.Pt.Angle)); PointD segment_end_point = new PointD(ptFinSegmentCourant.Pt.Distance * Math.Cos(ptFinSegmentCourant.Pt.Angle), ptFinSegmentCourant.Pt.Distance * Math.Sin(ptFinSegmentCourant.Pt.Angle)); if (Toolbox.Distance(segment_start_point, segment_end_point) >= minimum_distance) { segmentList.Add(new SegmentExtended(segment_start_point, segment_end_point, Color.Orange, 5)); } } segmentEnCours = false; } } return(segmentList); }