private void CheckNotSegmentException(FixedVertex2D a, FixedVertex2D b) { if (a.Coordinates == b.Coordinates) { throw new System.Exception("Begin == End"); } }
//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"); } }
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); }
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); }
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); }
public FixedCircle2D(FixedVertex2D center, Fixed radius) { this.Radius = radius; this.Center = center; }
public FixedVector2 GetDirectionTo(FixedVertex2D v) { return(new FixedVector2(v.coordinates.x - coordinates.x, v.coordinates.y - coordinates.y)); }
public void Vertex2DChangedEvent(FixedVertex2D vertex) { directionalVectorsRecalculationRequired = true; }
public void Vertex2DChangedEvent(FixedVertex2D vertex) { ActivateRecalculationFlags(); }