A room sketch can answer a small programming question: do two furniture footprints overlap, and does each footprint stay inside the room? Represent the room and each piece as rectangles, then run those checks whenever a coordinate changes. This gives you a repeatable way to compare a few layouts before ordering. Keep the sketch beside your measurements so that a change in the code can be checked against the room.Choose one coordinate systemUse centimetres throughout. Put the origin at the upper left corner of the plan, with x increasing to the right and y increasing downwards. Each rectangle has an x coordinate, a y coordinate, a width w and a height h. The coordinates describe its upper left corner. The width and height describe its footprint on the floor.The example uses a room measuring 420 by 320 centimetres. A sofa occupies a 200 by 90 rectangle at (40, 40). A table initially occupies a 100 by 60 rectangle at (160, 95). These dimensions are invented for the tutorial; they do not describe real products or a measured room. Axis-aligned rectangles keep the arithmetic short. A ninety-degree rotation swaps width and height; other angles require a different geometry test.Check overlap and room boundsTwo rectangles overlap when their horizontal intervals overlap and their vertical intervals overlap. The strict comparisons below count a shared edge as touching rather than overlap. Touching pieces have no gap between them, so a false overlap result alone says nothing about room to move, clean or open a drawer.Validate the numbers before comparing them. Number.isFinite rejects non-number values, NaN and infinities without converting strings. Positive widths and heights exclude empty or reversed rectangles. Negative coordinates remain valid inputs to the overlap function, while the room-bounds check rejects a piece placed beyond a wall.function checkBox(b) { if (!b || ![b.x, b.y, b.w, b.h].every(Number.isFinite) || b.w b.y;}function inside(box, room) { checkBox(box); checkBox(room); return box.x >= room.x && box.y >= room.y && box.x + box.w