private static bool IsContainOrigin(Triangle triangle) { double lengthFromP1P2 = GetLength(triangle.P1, triangle.P2, _origin); double lengthFromP2P3 = GetLength(triangle.P2, triangle.P3, _origin); double lengthFromP3P1 = GetLength(triangle.P3, triangle.P1, _origin); return ((lengthFromP1P2 > 0 && lengthFromP2P3 > 0 && lengthFromP3P1 > 0) || (lengthFromP1P2 < 0 && lengthFromP2P3 < 0 && lengthFromP3P1 < 0)); }
private static IList<Triangle> LoadTriangles(string path) { IList<string> strings = File.ReadAllLines(path); IList<Triangle> result = new List<Triangle>(); foreach (string triangleInStr in strings) { string[] pointsInStr = triangleInStr.Split( new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var triangle = new Triangle { P1 = new Point { X = int.Parse(pointsInStr[0]), Y = int.Parse(pointsInStr[1]) }, P2 = new Point { X = int.Parse(pointsInStr[2]), Y = int.Parse(pointsInStr[3]) }, P3 = new Point { X = int.Parse(pointsInStr[4]), Y = int.Parse(pointsInStr[5]) }, }; result.Add(triangle); } return result; }