Math Fundamentals18 sections · 814 units
Open in Course

Rectangle Area - Algorithm

(Step by step process)

1.1. Compute area1 = (x2a - x1a) × (y2a - y1a) 2.2. Compute area2 = (x2b - x1b) × (y2b - y1b) 3.3. Find intersection rectangle: - left = max(x1a, x1b) - right = min(x2a, x2b) - bottom = max(y1a, y1b) - top = min(y2a, y2b) 4.4. If left < right and bottom < top, overlap = (right - left) × (top - bottom) 5.5. Else, overlap = 0 6.6. Return area1 + area2 - overlap