/// <summary>
 /// Feature extraction. True if the polyline goes through the ball.
 /// </summary>
 /// <param name="b">The ball.</param>
 /// <returns>True if the polyline crosses the ball.</returns>
 public bool Crosses(Ball b)
 {
     bool res = false;
     for (int i = 0; i < _polylineX.Length; i++)
         res = res || ((_polylineX[i] - b.X) * (_polylineX[i] - b.X) + (_polylineY[i] - b.Y) * (_polylineY[i] - b.Y) < b.Radius * b.Radius);
     return res;
 }
コード例 #2
0
        /// <summary>
        /// Builds a cover from a .csv file.
        /// </summary>
        /// <param name="csvFilePath">.csv file containing the cover. Must contain a header.</param>
        public Cover(string csvFilePath)
        {
            using (StreamReader reader = new StreamReader(csvFilePath))
            {
                string line = "";
                reader.ReadLine(); // header
                while ((line = reader.ReadLine()) != null)
                {
                    string[] res = line.Split(',');
                    double x = Convert.ToDouble(res[0], CultureInfo.GetCultureInfo("en-US"));
                    double y = Convert.ToDouble(res[1], CultureInfo.GetCultureInfo("en-US"));
                    double radius = Convert.ToDouble(res[2], CultureInfo.GetCultureInfo("en-US"));

                    Ball current = new Ball(x, y, radius);
                    _balls.Add(current);
                    _names.Add(line.Replace(',', '_'));
                }
            }
        }