Apologies in advance as I might have a hard time wording this question properly, so I'll start by explaining my objective.
I'm currently working with JavaScript and Raphael.
My goal is to save the position of a point in relation to the four corners of a polygon. The polygon's opposite corners can be visualized as having axes connecting them, always meeting at a right angle with one another. While the polygon can be rotated and resized on either axis, the axes will remain perpendicular. I aim for the point to maintain its position on the polygon regardless of any movement or stretching. Users click on a spot on the polygon to place the point.
What I want is to convert mouse click X/Y coordinates into some relative percentage or another measurement based on the polygon's internal axes, which are not always aligned with the browser's X/Y axes. How can this be accomplished?
The following image illustrates the concept I'm trying to convey.
The green dot represents the point for which I need to store the relative position within the polygon. I have X/Y coordinates for the red and blue corner dots.