Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pie slice bounding rectangle

How can I calculate a pie slice bounding rectangle. Radius (r), center point (x0, y0) , StartAngle (a0), EndAngle (a1) and drawDirection (clockwise or counterclockwise) variables are known.

like image 783
Pyramid Avatar asked Dec 21 '22 21:12

Pyramid


2 Answers

Compute the points at the end of the arc edge, the point at the center of the slice and any of the four extreme points (angles 0, 90, 180 and 270) if they are contained within the sweep angle. Then all you have to do is iterate over all the points and find the minimum and maximum x and y values.

like image 126
David Rutten Avatar answered Jan 17 '23 22:01

David Rutten


alt text

HTH!

like image 43
Dr. belisarius Avatar answered Jan 17 '23 22:01

Dr. belisarius