public static double CalAmpli(List <DataPosition> posi) { // TODO : Distance aussi en X !!! DataPosition depart = new DataPosition(posi.First().X, posi.First().Y); DataPosition best = new DataPosition(posi.First().X, posi.First().Y); foreach (var dp in posi) { if (dp.Y < best.Y) { best.Y = dp.Y; best.X = dp.X; } //if (dp.X < best.X) //{ // best.X = dp.X; //} } return(DistancePythagorean(depart.X, depart.Y, best.X, best.Y)); }
public static double PresciTarget(List <DataPosition> posi) { // TODO : Distance aussi en X !!! double distance = 0.0; DataPosition dt = new DataPosition(posi.First().X, posi.First().Y); foreach (var el in posi) { if (el.Y < dt.Y) { dt.Y = el.Y; } if (el.X < dt.X) { dt.X = el.X; // TODO : A CHANGER ! } } distance = (DistancePythagorean(dt.X, dt.Y, 42.6, 44.2)); return(distance); }
public static double CalAmpliFree(List <DataPosition> posi, ref double coordYMax) { DataPosition Bas = new DataPosition(posi.First().X, posi.First().Y); //DataPosition Haut = new DataPosition(posi.First().X, posi.First().Y); double distanceTot = 0.0; foreach (var dp in posi) { //if (dp.Y > Haut.Y) //{ // Haut = dp; //} if (dp.Y < Bas.Y) { Bas = dp; } } coordYMax = posi.First().Y - Bas.Y; distanceTot = DistancePythagorean(posi.First().X, posi.First().Y, Bas.X, Bas.Y); distanceTot += DistancePythagorean(Bas.X, Bas.Y, posi.Last().X, posi.Last().Y); return(distanceTot); }
public static double PreciCercle(List <DataPosition> Posi, DataPosition CentreCercle, double RayonCercle) { double Preci = 0.0; List <DataPosition> PosiProj = new List <DataPosition>(); List <double> ListeDist = new List <double>(); for (int dp = 0; dp < Posi.Count; dp++) { double vccpc_X = Posi[dp].X - CentreCercle.X; double vccpc_Y = Posi[dp].Y - CentreCercle.Y; double alpha = RayonCercle / Math.Sqrt(Math.Pow(vccpc_X, 2) + Math.Pow(vccpc_Y, 2)); PosiProj.Add(new DataPosition(CentreCercle.X + alpha * vccpc_X, CentreCercle.Y + alpha * vccpc_Y)); ListeDist.Add(Math.Sqrt(Math.Pow((PosiProj[dp].X - Posi[dp].X), 2) + Math.Pow((PosiProj[dp].Y - Posi[dp].Y), 2))); } //m < Compteur (qui ici est 1) //for (int m = 0; m < 1; m++) //{ // double distance_moyenne_cycle = 0.0; // int PointDep = 1; // distance_moyenne_cycle = distance_moyenne_cycle + ListeDist[PointDep - 1]; // Preci += distance_moyenne_cycle; //} for (int m = 0; m < ListeDist.Count; m++) { //double distance_moyenne_cycle = 0.0; //int PointDep = 1; Preci += ListeDist[m]; //Preci += distance_moyenne_cycle; } return(Preci / ListeDist.Count); }
public static double PreciCarre(List <DataPosition> Posi, DataPosition CentreCarre, double LongCotCarre, double OrientCarre) { double Preci = 0.0; List <DataPosition> PosiProj = new List <DataPosition>(); List <DataPosition> RefShape = new List <DataPosition>(); List <double> ListeDist = new List <double>(); double posiProjTempX, posiProjTempY; double Ns = 5; for (int ind = 0; ind < Ns; ind++) { RefShape.Add(new DataPosition(CentreCarre.X + (LongCotCarre / 2.0) * (Math.Sin(OrientCarre + ind * Math.PI / 2.0) + Math.Cos(OrientCarre + ind * Math.PI / 2.0)), CentreCarre.Y + (LongCotCarre / 2.0) * (Math.Cos(OrientCarre + ind * Math.PI / 2.0) - Math.Sin(OrientCarre + ind * Math.PI / 2.0)))); } for (int dp = 0; dp < Posi.Count; dp++) { ListeDist.Add(100.0); // Initialisation for (int j = 0; j < Ns - 1; j++) // parcours de tous les segments de la trajectoire de référence { // Calcul du point projeté double vsipc_X = Posi[dp].X - RefShape[j].X; double vsipc_Y = Posi[dp].Y - RefShape[j].Y; double vsisf_X = RefShape[j + 1].X - RefShape[j].X; double vsisf_Y = RefShape[j + 1].Y - RefShape[j].Y; double alpha = (vsipc_X * vsisf_X + vsipc_Y * vsisf_Y) / Math.Sqrt(Math.Pow(vsisf_X, 2.0) + Math.Pow(vsisf_Y, 2.0)); if (alpha <= 0.0) { posiProjTempX = RefShape[j].X; posiProjTempY = RefShape[j].Y; } else { if (alpha >= 1.0) { posiProjTempX = RefShape[j + 1].X; posiProjTempY = RefShape[j + 1].Y; } else { posiProjTempX = RefShape[j].X + alpha * vsipc_X; posiProjTempY = RefShape[j].Y + alpha * vsipc_Y; } } double DistTemp = Math.Sqrt(Math.Pow((posiProjTempX - Posi[dp].X), 2.0) + Math.Pow((posiProjTempY - Posi[dp].Y), 2.0)); if (DistTemp < ListeDist[dp]) // Mise à jour du point projeté le plus proche de la distance correspondante { ListeDist[dp] = DistTemp; PosiProj.Add(new DataPosition(posiProjTempX, posiProjTempY)); } } } //m < Compteur (qui ici est 1) //for (int m = 0; m < 1; m++) //{ // double distance_moyenne_cycle = 0; // int PointDep = 1; // distance_moyenne_cycle = distance_moyenne_cycle + ListeDist[PointDep - 1]; // Preci += distance_moyenne_cycle; //} for (int m = 0; m < ListeDist.Count; m++) { //double distance_moyenne_cycle = 0.0; //int PointDep = 1; Preci += ListeDist[m]; //Preci += distance_moyenne_cycle; } return(Preci / ListeDist.Count); }