I am trying to find a transformation that takes me between Cartesian coordinates and a pseudo-coordinate-system I have developed which is described as follows:
Please first see the diagram below.
Before I go into details, I would also like to make it clear that I am hoping for a push in the right direction towards solving this problem, although a thorough solution is more than welcome.
Given a straight line segment (red) of length $l$, there are a series of finite points which define the coordinates. These points are constructed as 'equally spaced' dotted lines (all of length $m$), the first of which is at an angle $\theta$ 'clockwise' to the segment perpendicular and rotates regularly up to the end of the segment, at which point the dotted line is at an angle $\phi$ 'anticlockwise' to the segment perpendicular. (As such the most vertical dotted line isn't necessarily at the middle of the segment.)
Within each dotted line, the dots are spaced equally, a distance $d$ apart.
The dotted lines are spaced equally along the segment, a distance $s$ apart.
Specifically I want to devise an algorithm which can map a Cartesian coordinate to the closest point in the coordinate system just described (taking care to state that there is no closest point if it lies outside of the trapezoid [noting that the outermost points still have a finite surrounding area - a smaller trapezoid to be exact]).
This will be coded up, so computational efficiency is a minor goal.
Many thanks in advance.
EDIT: If this problem is too difficult, then a solution for when $\theta = \phi$ (so a vertical dotted line is in the middle of the segment, as in the diagram) would still be useful.