Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am working on a program where I am programmatically drawing shapes for visual representations of objects. I am a bit stuck on some math and was wanting some help.

The object I am drawing is a guage face, with a bezel type border. The program must support all starting and finishing angles (i.e. 0 to 180 degs, 30 to 150 degs, 270 to 230 degs). Ignore the case of a total angle of greater than 180 degrees for now. The edge of the border is a distance d away from the edge of the face.

The inputs to my system are just that of a diameter of the gauge, the starting angle of the gauge, and the end point of the gauge.

I can easily derive the inner points of the gauge face, assuming (0,0) as the center, the angles have been converted to radians (theta start and theta end), and w is the width of the bezel in terms of a percentage of the entire gauge.

R1 = diameter/2
R2 = R1 * (1 - w)
d = R1 - R2
theta_avg = (theta_start + theta_end)/2
P0 = (0,0)  //Center point
P1 = (R2*cos(theta_start),R2*sin(theta_start))  //End point 1
P2 = (R2*cos(theta_avg),R2*sin(theta_avg))  //Center of arc
P3 = (R2*cos(theta_end),R2*sin(theta_end))  //End point 2

Now I need the outer edge for the border. The border should be made up of a line that is parallel to the line from P0 to P1 and another line that is parallel to the line from P0 to P3. These lines should be a consistent distance d away. There is an arc of distance d away around the small arc (already done). There will be curves connecting the points together, but do not worry about that right now.

Thanks for the help. Please do not hesitate to ask for any clarifications or for any extra information. The links below show what I have so far, and a hand drawn version of what I am trying to achieve.

Can anyone please give some insight as to what I need to do in order to draw these lines.

What I Have

Have

What I Need

Need

Should also mention that P6 and P7 are obviously easy to find using the start and end angles and R1. Points P8, P9, P4, and P5 are the main ones that I need (or the equation of the line so I can find those points).

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

Define the gauge angle $\theta=$theta_end-theta_start. For P4 you want to extend the line P3P0 by $\frac{d}{\sin \theta}$, so P4$=(-\frac{d}{\sin \theta}\cos{\theta_{end}},-\frac{d}{\sin \theta}\sin{\theta_{end}})$ Similarly P9$=(-\frac{d}{\sin \theta}\cos{\theta_{start}},-\frac{d}{\sin \theta}\sin{\theta_{start}})$. P6 and P7 are just extensions of the line from P0 by $d$, so P7$=((R1\cos{\theta_{end}},R1\sin{\theta_{end}})$, P6$=((R1\cos{\theta_{start}},R1\sin{\theta_{start}})$. Probably P5 and P8 should be along the tangents through P1 and P3, not on the continuation of the arc P1P2P3. Then P8=P3$+(d\sin\theta_{end},-d\cos\theta_{end})$, P5=P1$+(d\sin\theta_{start},-d\cos\theta_{start})$

share|improve this answer
    
Thanks for your quick reply. I will try it out and get back to you. –  jyore Oct 18 '11 at 20:34
    
Just tested it out, and it works like a charm. Thanks again for your help. –  jyore Oct 18 '11 at 21:13
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.