I stumbled upon the need to get a random point on the perimeter of a rectangle while making a game, the solution programmatically is easy enough, tho i was curious of a mathematical solution too.
Say we have a random Distance we want to travel from the TopLeft corner of the rectangle along all its sides. We known the Width and Height of the rectangle, including the Distance or Length that we'll travel around it.
Our point will only ever be on the edge of the rectangle and never inside it.
Is there a simple equation to get the X,Y coordinates?
Note that our random Distance can be the full perimeter of the rectangle, having us travel all around it completely.