public Rectangle(Point a , Point b) { if(a.x == b.x || a.y == b.y) { throw new ArgumentException ("The points cannot be on the same axis , they must be oposite corners in the rectangle"); } else { corner1 = a; corner2 = b; int ax = a.x; int bx = b.x; int ay = a.y; int by = b.y; Point br = new Point(ax, by); corner3 = br; Point br2 = new Point(ay, bx); corner4 = br2; LineSegment l1 = new LineSegment(corner1,corner4); LineSegment l2 = new LineSegment(corner1, corner3); LineSegment l3 = new LineSegment(corner2, corner3); LineSegment l4 = new LineSegment(corner2, corner4); lineone = l1; linetwo = l2; linethree = l3; linefour = l4; } }
public LineSegment(LineSegment ls) { if(q) { this.point1 = ls.point1; this.point2 = ls.point2; } }
private KeyValuePair<float, float> GetRectangleCenter(LineSegment a , LineSegment b) { float one = (float)(a.GetLenght(a) / 2); float two = (float)(b.GetLenght(b)/2); KeyValuePair<float, float> kvp = new KeyValuePair<float, float>(one,two); return kvp; }
public double GetLenght(LineSegment line) { double len = 0; int a, b; a = line.point2.x - line.point1.x; b = line.point2.x - line.point1.y; len = Math.Sqrt(a * a + b * b); return len; }