Assume
Points of rectangle R1: R1.A(x,y), R1.B(x,y), R1.C(x,y), R1.D(x,y) Points of rectangle R2: R2.A(x,y), R2.B(x,y), R2.C(x,y), R2.D(x,y) Overlapping rectangle RO: RO.A(x,y), RO.B(x,y), RO.C(x,y), RO.D(x,y) Standard cartesian coordinates (positive is right and upwards).
The overlapping rectangle RO computes as follows using C #:
RO.Ax = Math.Min(R1.Ax, R2.Ax); RO.Ay = Math.Max(R1.Ay, R2.Ay); RO.Cx = Math.Max(R1.Cx, R2.Cx); RO.Cy = Math.Min(R1.Cy, R2.Cy); RO.B(x,y) and RO.D(x,y) = ....
Inner RI Rectangle:
Change Min and Max in the above solution to overlap the RO rectangle.
user319785
source share