I'm trying to achieve something on JS which probably is not that hard, but not for my brain, unfortunately.
I have 4 arrays which are corners forming a rectangle in two-dimensional space.
var corner1 = [x, y];
var corner2 = [x, y];
var corner3 = [x, y];
var corner4 = [x, y];
I have a point which is inside that rectangle (I don't have to check that).
var point = [x, y]
I need to find the closest location to that point which is just next to the closest edge.
Here is a picture which describes better what I want to achieve.