a thoughtful web.
Good ideas and conversation. No ads, no tracking.   Login or Take a Tour!
comment
sphericalvoxel  ·  4361 days ago  ·  link  ·    ·  parent  ·  post: A fun little geometry problem

Okay, I've been sorta thinking, and I may have your geometry answer. Though I won't actually answer it, since I've already spent my work-day debugging code, this should at least give you all the tools needed.

So here's my diagram for you. It should go without saying that we want to find the length of L. Also note that I've defined the top-left point of the rectangle as the origin.

The first step is to transform the left rectangle into the right one. This is done with a rotation about the origin by omega, by for example multiplying each point by a 2D rotation matrix. The rotation doesn't change the fact that the top-left point, now called A, is at the origin. Otherwise, it's now up to you to solve for the other points.

One important observation is that this rotation makes the y-coordinate of point C zero. That is, C = (Cx, Cy) = (Cx, 0). This also means that position m is (0.5 * Cx, 0).

Now the next thing we want to know is how far along the line AB you'd have to travel to find the intersection with L. Since L is perpendicular to the x-axis, we can do this by projecting AB onto the x-axis, which, since A lies at the origin, is just Bx. The percentage of AB you have to traverse before you reach L (when starting from A) is mx / Bx. So let's call this theta.

The answer now is the amount you'd have to travel along AB in the y-direction, which is, theta*By. And this is the length of L. So now twice that is your answer.

I don't really have the energy (or the diagrams) to justify this answer, but if you want to verify, I'd appreciate knowing if my logic is in fact sound. I've more developed a sense for geometry that has killed what little ability I once had for formal proofs... but then, since my sense for geometry is sometimes wrong, I now write code to verify, if being right matters.