/// <summary> /// Function that calculates the total are of an arc including the /// area that is occupied by a trapezoid under the arc /// </summary> /// <param name="arc">The arc</param> /// <returns>The Area of the Arc and Trapezoid</returns> private double CalcAreaGeoArc(GeoArc arc) { var sumArea = 0.0; // Determine if the function should subtract the // bulge if (SubtractBulge(arc.BulgeValue)) { sumArea -= arc.Area; } else { sumArea += arc.Area; } // Determine if the function should subtract the line // that is underneath the bulge as well GeoLine line; if (IsCounterClockWise) { line = new GeoLine(arc.Vertex1, arc.Vertex0); } else { line = new GeoLine(arc.Vertex0, arc.Vertex1); } sumArea += line.Area; return(sumArea); }
/// <summary> /// The Main GeoPolyLine Constructor /// </summary> /// <param name="xValues">X Coordinates</param> /// <param name="yValues">Y Coordinates</param> /// <param name="bulgeList">A List of Bulges</param> /// <param name="polylineFlag">The isClosed Property of a polyline</param> public GeoPolyline(List <double> xValues, IReadOnlyList <double> yValues, IReadOnlyList <double> bulgeList, bool polylineFlag) { // Throw Exception if the number of vertices does not match the if (xValues.Count != yValues.Count) { throw new EntityException("There must be a matching number of vertices"); } // Initialize and preallocate the vertex list Vertices = new List <Vertex>(xValues.Capacity); // Initializing a pre-allocating the section list SectionList = polylineFlag ? new List <GeoBase>(Vertices.Capacity) : new List <GeoBase>(Vertices.Capacity - 1); // Place x and y into the vertices list Vertices.AddRange(xValues.Select((t, vertexIndex) => new Vertex(t, yValues[vertexIndex]))); // Iterate through all of the vertices and build either GeoArcs or GeoLines for (var vertexIndex = 0; vertexIndex < Vertices.Count; ++vertexIndex) { var currentVertex = Vertices[vertexIndex]; var nextVertex = vertexIndex == Vertices.Count - 1 ? Vertices[0] : Vertices[vertexIndex + 1]; if (Math.Abs(bulgeList[vertexIndex] - Bulge.BulgeNull) > GeoMath.Tolerance) { var geoArc = new GeoArc(currentVertex, nextVertex, bulgeList[vertexIndex]); geoArc.PropertyChanged += GeoArcOnPropertyChanged; SectionList.Add(geoArc); } else { var geoLine = new GeoLine(currentVertex, nextVertex); geoLine.PropertyChanged += GeoLineOnPropertyChanged; SectionList.Add(new GeoLine(currentVertex, nextVertex)); } if (!polylineFlag) { SectionList.RemoveAt(SectionList.Count - 1); } } UpdateGeometry(string.Empty); }
/// <summary> /// The Area between a Geoline and the x-axis /// </summary> /// <param name="line">The line that defined the area</param> /// <returns>The area between a GeoLine and the x-axis</returns> public static double TrapzArea(GeoLine line) { return((line.Vertex1.Y + line.Vertex0.Y) / 2 * (line.Vertex1.X - line.Vertex0.X)); }