What is a way that I can calculate the width of a convex polygon given its vertices and some angle? The purpose of this is to find the cross sectional width of a polygon moving at some velocity in order to calculate some kind of air drag during a simulation.
I guess the biggest problem is that I don't have more than a basic understanding of geometry right now, so I'm not sure I would recognize the solution if I saw it. The closest algorithms I could find deal with finding the minimum width of a polygon, but I'm really looking for the width in the direction of some velocity. I'm a bit stumped.
Just rotate all vertices of polygon by needed angle and find difference of maximum and minimum Y-coordinates of vertices (for example, for zero angle width along X-axis is Ymax-Ymin).
Rotation_matrix is here. Rotated coordinates of vertice are:
x'=x*Cos(Fi)-y*Sin(Fi)
y'=x*Sin(Fi)+y*Cos(Fi)
Note that you need to find only y'