refactor shapes, use mid_y for a corner
Reverse engineering and debugging reveal that:
- AF is corners array of a bounding box:
AF[3]───────AF[2]
│ │
mid_y(&AF[1])→ │ midpoint │
│ │
AF[0]───────AF[1]
↑
mid_x(AF)
- AF[3] is top left corner of the bounding box
- AF[3].y == AF[2].y
- AF[0] is bottom left corner of the bounding box
- AF[0].y == AF[1].y
Refactoring:
AF[2].y + (AF[0].y - AF[3].y)/2
-> AF[2].y + (AF[1].y - AF[2].y)/2
-> AF[2].y/2 + AF[1].y/2
-> (AF[2].y + AF[1].y)/2
-> mid_y(&AF[1])
Edited by Costa Shulyupin