Given a circular sector defined by sweeping from a 'start' to a 'stop' angle (see diagram below) and a radius, how do you compute the bounds of the rectangle that fits to the edges of the sector? Additionally, assuming that the top left corner of the rectangle is at (0, 0), where is the center of the arc within the rectangle?
The diagram below should clarify all the assumptions in my situation and gives two examples of the sectors I can have. The red rectangle is the rectangle of interest. Please note the particular challenges:
Sweeping direction is always clockwise, and sectors can extend past 180 degrees. Naming convention (i.e. 0 degrees is at 3 o'clock) as shown.
Angles can wrap around +/- 180 degrees; -10 and 190 are equivalent, but this means that any calculations of angular distances (if needed) need to account for that. For example, with a start angle of 170 and a stop of -170, the angle of the sector is only 20, not -340 (which is what a blind application of 'stop' - 'start' would give you)
One final complication: the coordinate system I am working in has the origin at the top left rather than bottom left, so the bottom right corner of the rectangle will have positive x and y coordinates.
If anyone's curious, this is for computer graphics in a user interface. The circular sector is actually broken into a 'wheel' of menu options, and I need its size to be able to lay out other UI elements around it. The position of the center of the circular sector is required to determine whether a mouse click is within an element or not.
Thank you!