public override bool Equals(Shape2D lineSegment, double epsilon = 1e-5)
        {
            if (lineSegment is LineSegment2D compare)
            {
                int equalCount = 0;

                for (int i = 0; i < PointList.Count; i++)
                {
                    for (int j = 0; j < compare.PointList.Count; j++)
                    {
                        if (PointList[i].Equals(compare.PointList[j], epsilon))
                        {
                            equalCount++;
                            break;
                        }
                    }
                }

                return(equalCount == 2);
            }
            else
            {
                return(false);
            }
        }
        public override bool Equals(Shape2D triangle, double epsilon = 1e-5)
        {
            if (triangle is Triangle2D compare)
            {
                int equalCount = 0;

                for (int i = 0; i < PointList.Count; i++)
                {
                    for (int j = 0; j < compare.PointList.Count; j++)
                    {
                        if (PointList[i].Equals(compare.PointList[j], epsilon))
                        {
                            equalCount++;
                            break;
                        }
                    }
                }

                return(equalCount == 3);
            }
            else
            {
                return(false);
            }
        }
Exemple #3
0
 public override bool Equals(Shape2D circle, double epsilon = 1e-5)
 {
     if (circle is Circle2D compare)
     {
         return(Center.Equals(compare.Center) && Utilities.SameValue(Radius, compare.Radius, epsilon));
     }
     else
     {
         return(false);
     }
 }
 public override Shape2D IntersectingShape(Shape2D shape)
 {
     if (shape is LineSegment2D lineSegment)
     {
         return(IntersectingShape(lineSegment));
     }
     else
     {
         return(new EmptyShape2D());
     }
 }
Exemple #5
0
 public override bool Equals(Shape2D point, double epsilon = 1e-5)
 {
     if (point is Point2D compare)
     {
         return((Math.Abs(X - compare.X) < epsilon) && (Math.Abs(Y - compare.Y) < epsilon));
     }
     else
     {
         return(false);
     }
 }
 public override bool Equals(Shape2D ray, double epsilon = 1e-5)
 {
     if (ray is Ray2D)
     {
         return(false);
     }
     else
     {
         return(false);
     }
 }
Exemple #7
0
 public abstract bool Equals(Shape2D shape, double epsilon = 1e-5);
Exemple #8
0
 public virtual Shape2D IntersectingShape(Shape2D shape)
 {
     //TODO: we actually need to throw an exception here
     return(new EmptyShape2D());
 }
 public override bool Equals(Shape2D emptyShape, double epsilon = 1e-5)
 {
     return(this.GetType().Equals(emptyShape.GetType()));
 }
Exemple #10
0
 public override bool Equals(Shape2D line, double epsilon = 1e-5)
 {
     return(false);
 }