/// <summary> /// Updates the mid point locations of all the intercept/intervals contained in the list. /// </summary> public void UpdateMergedListInterceptMidPoints() { if (Count == 0) { return; } for (int i = 0; i < Count - 1; i++) { // Grab a pair of adjacent intercepts InterceptRec InterceptA = Items[i]; InterceptRec InterceptB = Items[i + 1]; double IntLength = MathUtilities.Hypot(InterceptB.OriginX - InterceptA.OriginX, InterceptB.OriginY - InterceptA.OriginY); // Calculate the midpoint of the line between the pair of intercepts double MPX = (InterceptA.OriginX + InterceptB.OriginX) / 2; double MPY = (InterceptA.OriginY + InterceptB.OriginY) / 2; Items[i] = new InterceptRec(Items[i].OriginX, Items[i].OriginY, MPX, MPY, Items[i].ProfileItemIndex, IntLength); } // Discard the last intercept as it's already been used as the end point of the previous pair of intercepts Count--; }
/// <summary> /// Adds a new point to the list, unless the point being added is equal to the last point in the list /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="ind"></param> public void AddPoint(double x, double y, double ind) { if (Count > 0 && Items[Count - 1].Equals(x, y, ind) || Count >= MaxIntercepts) { return; } if (Count >= Items.Length) { Array.Resize(ref Items, Items.Length + ListInc); } Items[Count] = new InterceptRec { OriginX = x, OriginY = y, ProfileItemIndex = ind }; Count++; }
/// <summary> /// Adds a new point to the list, unless the point being added is equal to the last point in the list /// </summary> /// <param name="point"></param> public void AddPoint(InterceptRec point) { if (Count > 0 && Items[Count - 1].Equals(point)) { return; } if (Count >= MaxIntercepts) { return; } if (Count >= Items.Length) { Array.Resize(ref Items, Items.Length + ListInc); } Items[Count] = point; Count++; }