I'm trying to determine the 'diameter' or distance across a given rectangle for a given angle. Ideally there should be a function f(theta) that takes a polar angle and determines the distance across the rectangle.
For example, with a rectangle with width w (from -w/2 to w/2) and height h (-h/2, h/2) and centered at (0,0):
f(0) should be the width w.
f(PI/2) should be the height h.
f(atan(h / w)) should be the diagonal.
Outside of these three cases, I'm not entirely sure how to interpolate points.
- Is there a closed form solution (or approximation)? Probably not.
- Do I interpolate between those three points with a piecewise function? Probably.
- Would such a function use linear, quadratic, or some other interpolation? How would I determine this?
thanks for your help!
The width is the projection of the diagonal $d$ on the direction, i.e., $$ d \cos(\theta - \tan^{-1}\frac{h}{w}) $$