I am trying to programatically draw a circle with a diamond hatch pattern in it.
To do so I need to work out the x/y coords that each line intersects the circle. I know the x/y coords of the circle origin, the radius of the circle and the width and height of each diamond (the height being generally greater than the width, which my illustration doesn't convey very well!).
Just considering the lines that run from south-west to north-east of the circle, I have had partial success by approaching this as follows:
1. Solve the red triangle in order to determine angle C
2. Work out the number of lines either side of origin, in any direction, by working out the height/altitude of the diamond parallelogram
3. Establish the point where the first or outermost line intersects with the x axis (point 1) and loop from left to right through each point 1-5
4. For each point, solve a triangle that goes from the current x axis point to the target point on the circumference and on to the circle origin - the green triangle in the second image (we know green angle C and sides a and c).
5. That then gives us the length of green side b from which we solve a right angled triangle going from the current x axis point to the target point on the circumference and down to the x axis.
6. That last solve gives us enough information to work out where the x/y coords of the target circumference point is
Of course, once I get to points 4 and 5 on the x axis I have to alter the formula that solves the triangle at step 4 above as the known radius side becomes side b instead of c and the known angle becomes B instead of C.
However I start either getting two possible solutions to the triangle or no solution at all once angle B becomes too great, such as when trying to solve the magenta triangle at x axis position 5 in the 3rd image. It gets worse when I start trying to work out the lines going from north-west to south-east.
Has anyone got any ideas on a foolproof way of working out the various points? The width and height of the diamonds can vary as can the circle radius.