Example #1
0
 public static Segment GetCommonSegmentFromTwoTriangles(Triangle a, Triangle b)
 {
     if (a.S1.Egale(b.S1) || a.S1.Egale(b.S2) || a.S1.Egale(b.S3))
         return a.S1;
     if (a.S2.Egale(b.S1) || a.S2.Egale(b.S2) || a.S2.Egale(b.S3))
         return a.S2;
     if (a.S3.Egale(b.S1) || a.S3.Egale(b.S2) || a.S3.Egale(b.S3))
         return a.S3;
     return new Segment(new Point(0,0), new Point(0, 0));
 }
Example #2
0
 public static bool CanDraw(Point p, Point x)
 {
     var ls = SegmentsManager.GetSegmentsThatContainsASpecificPoint(p);
     var p1 = ls[0].GetTheOtherPoint(p);
     var p2 = ls[1].GetTheOtherPoint(p);
     var tr = new Triangle(p, p1, p2);
     if (TriangleManager.CheckIfAPointIsInsideATriangle(x, tr))
         return false;
     return true;
 }
Example #3
0
 public static bool CheckIfAPointIsInsideATriangle(Point p,Triangle t)
 {
     if (p != t.A && p != t.B && p != t.C)
         {
             var a = CalculateArea(t.A, t.B, t.C);
             var a1 = CalculateArea(p, t.A, t.B);
             var a2 = CalculateArea(p, t.B, t.C);
             var a3 = CalculateArea(p, t.A, t.C);
             if (Math.Abs(a - (a1 + a2 + a3)) < 0.001)
                 return true;
         }
     return false;
 }
Example #4
0
 public static bool CheckIfPointIsInsideTriangle(Triangle t)
 {
     foreach (var p in PolygonManager.GetAllPoints())
     {
         if (p != t.A && p != t.B && p != t.C)
         {
             var a = CalculateArea(t.A, t.B, t.C);
             var a1 = CalculateArea(p, t.A, t.B);
             var a2 = CalculateArea(p, t.B, t.C);
             var a3 = CalculateArea(p, t.A, t.C);
             if (Math.Abs(a - (a1 + a2 + a3)) < 0.001)
                 return true;
         }
     }
     return false;
 }
Example #5
0
 public static bool CheckIfTriangleIsAShape(Triangle t)
 {
     return ListOfPolygons.Select(p => p.Segmente).Where(ls => ls.Count == 3).Any(ls => (ls[0].Egale(t.S1) || ls[0].Egale(t.S2) || ls[0].Egale(t.S3)) && (ls[1].Egale(t.S1) || ls[1].Egale(t.S2) || ls[1].Egale(t.S3)) && (ls[2].Egale(t.S1) || ls[2].Egale(t.S2) || ls[2].Egale(t.S3)));
 }
Example #6
0
 public static List<Triangle> GetAllTrianglesNextToMainTriangle(Triangle mainT)
 {
     return Triangles.Where(t => !t.Equals(mainT)).Where(t => (t.S1.Egale(mainT.S1)) || (t.S1.Egale(mainT.S2)) || (t.S1.Egale(mainT.S3)) || (t.S2.Egale(mainT.S1)) || (t.S2.Egale(mainT.S2)) || (t.S2.Egale(mainT.S3)) || (t.S3.Egale(mainT.S1)) || (t.S3.Egale(mainT.S2)) || (t.S3.Egale(mainT.S3))).ToList();
 }
Example #7
0
 public static bool CheckIfTriangleAlreadyExists(Triangle t)
 {
     return Triangles.Any(tr => (t.A.Equals(tr.A) || t.A.Equals(tr.B) || t.A.Equals(tr.C)) && (t.B.Equals(tr.A) || t.B.Equals(tr.B) || t.B.Equals(tr.C)) && (t.C.Equals(tr.A) || t.C.Equals(tr.B) || t.C.Equals(tr.C)));
 }