private float[,,] segmentLine(float width, int segments) { #if DEBUG Console.WriteLine("Unique Locations: " + _st.GetUniqueLocations().Count); #endif float[,,] r = new float[_st.GetUniqueLocations().Count, segments + 1, 2]; _normalizedFrequency = new float[_st.GetUniqueLocations().Count]; float maxFrequency = _st.GetMaxFrequency(); _kp = new float[_st.GetUniqueLocations().Count]; float ylat, ylng, slope, intercept, incx; //float kp = (float)(K / (Math.Pow(Math.Pow(ylng - ylat, 2) + width * width, 0.5))); Parallel.For(0, _st.GetUniqueLocations().Count, (i) => //for (int i = 0; i < _st.GetUniqueLocations().Count; i++) { ylat = _st.GetUniqueLocations()[i][0]; ylng = _st.GetUniqueLocations()[i][1]; slope = (ylng - ylat) / width; intercept = ylat; incx = width / segments; for (int j = 0; j <= segments; j++) { r[i, j, 0] = incx * j; r[i, j, 1] = (slope * r[i, j, 0]) + intercept; } float t = _st.GetUniqueLocations()[i][2]; _normalizedFrequency[i] = (t / maxFrequency); // < 0.5f ? 0.3f : (t / maxFrequency); // Using rectilinear metric _kp[i] = t; // / Math.Abs(ylng - ylat+ width); //(float)( t / (Math.Abs(ylng - ylat) )); //_kp[i] = (float)(_st.GetUniqueLocations()[i][2] / ((ylng - ylat) + width)); } ); return(r); }
private float[,,] segmentLines(float width, int segments) { #if DEBUG Console.WriteLine("Starting Segmentation at: " + DateTime.Now.ToString()); #endif /// 3D array of floats containing - Locations, their segments, x,y coordinate of the segments float[, ,] r = new float[_st.GetUniqueLocations().Count, segments + 1, 2]; /// maxFrequency is used later to compute the stiffness of a line i.e, more points it has, more stiff it is float maxFrequency = _st.GetMaxFrequency(); /// Stiffness constant, kp _kp = new float[_st.GetUniqueLocations().Count]; float ylat, ylng, slope, intercept, incx; for (int i = 0; i < _st.GetUniqueLocations().Count; i++) { ylat = _st.GetUniqueLocations()[i][0]; ylng = _st.GetUniqueLocations()[i][1]; slope = (ylng - ylat) / width; intercept = ylat; incx = width / segments; for (int j = 0; j <= segments; j++) { r[i, j, 0] = incx * j; r[i, j, 1] = (slope * r[i, j, 0]) + intercept; } //_kp[i] = (_st.GetUniqueLocations()[i][2] / maxFrequency);// < 0.5f ? 0.3f : (t / maxFrequency); _kp[i] = _st.GetUniqueLocations()[i][2]; } #if DEBUG Console.WriteLine("Completing Segmentation at: " + DateTime.Now.ToString()); #endif return r; }