示例#1
0
 private void CheckNotSegmentException(FixedVertex2D a, FixedVertex2D b)
 {
     if (a.Coordinates == b.Coordinates)
     {
         throw new System.Exception("Begin == End");
     }
 }
示例#2
0
        //TODO: I can use CheckNotTriangleException but i don't know is it neccessary
        private void CheckNotTriangleException(FixedVertex2D a, FixedVertex2D b, FixedVertex2D c)
        {
            FixedVector2 ab = a.GetDirectionTo(b);
            FixedVector2 ac = a.GetDirectionTo(c);

            if ((ab.x * ac.y - ab.y * ac.x).IsZero())
            {
                throw new System.ArgumentException("This set of vertices can't form the triangle");
            }
        }
示例#3
0
        public FixedRectangle2D(Fixed leftX, Fixed bottomY, Fixed width, Fixed height)
        {
            FixedVector2 a = new FixedVector2(leftX, bottomY);
            FixedVector2 b = new FixedVector2(leftX + width, bottomY);
            FixedVector2 c = new FixedVector2(leftX + width, bottomY + height);
            FixedVector2 d = new FixedVector2(leftX, bottomY + height);

            this.a = new FixedVertex2D(a);
            this.b = new FixedVertex2D(b);
            this.c = new FixedVertex2D(c);
            this.d = new FixedVertex2D(d);
            abc    = new FixedTriangle2D(this.a, this.b, this.c);
            acd    = new FixedTriangle2D(this.a, this.c, this.d);
        }
示例#4
0
 public FixedTriangle2D(FixedVertex2D a, FixedVertex2D b, FixedVertex2D c)
 {
     if (a == null || b == null || c == null)
     {
         throw new System.ArgumentNullException("a==null||b==null||c==null");
     }
     //CheckNotTriangleException (a,b,c);
     this.a = a;
     this.b = b;
     this.c = c;
     this.a.AddVertex2DChangeListener(this);
     this.b.AddVertex2DChangeListener(this);
     this.c.AddVertex2DChangeListener(this);
 }
示例#5
0
 public FixedSegment2D(FixedVertex2D begin, FixedVertex2D end)
 {
     if (begin == null || end == null)
     {
         throw new System.ArgumentNullException();
     }
     if (begin.Coordinates == end.Coordinates)
     {
         throw new System.Exception("End == Begin");
     }
     this.begin = begin;
     this.end   = end;
     this.begin.AddVertex2DChangeListener(this);
     this.end.AddVertex2DChangeListener(this);
 }
示例#6
0
 public FixedCircle2D(FixedVertex2D center, Fixed radius)
 {
     this.Radius = radius;
     this.Center = center;
 }
示例#7
0
 public FixedVector2 GetDirectionTo(FixedVertex2D v)
 {
     return(new FixedVector2(v.coordinates.x - coordinates.x, v.coordinates.y - coordinates.y));
 }
示例#8
0
 public void Vertex2DChangedEvent(FixedVertex2D vertex)
 {
     directionalVectorsRecalculationRequired = true;
 }
示例#9
0
 public void Vertex2DChangedEvent(FixedVertex2D vertex)
 {
     ActivateRecalculationFlags();
 }