Mini-Challenge #2
-
http://youtu.be/_0TY6HHL25Y
A graphical solution. -
@sdmitch said:
A graphical solution.
hey sdmitch..
that's only doing one side of it though.. the difficulty comes when trying to fit the rectangle between two corners.
do you have a solution for that? -
@jeff hammond said:
@sdmitch said:
A graphical solution.
hey sdmitch..
that's only doing one side of it though.. the difficulty comes when trying to fit the rectangle between two corners.
do you have a solution for that?You have to repeat the process on the other end also of course. Connecting those lines to create a face produces a slightly skewed rectangle. Rotating the ends to create a regular rectangle moves the ends but, in my test, by less than 0.01" from the edge. The perfect solution would require several iterations.
-
Each of the two corners have two extreme limits.
Where the 'x' width of the inscribed rectangle's end meet at 90 degrees.
These limits have an 'overlap' at each end.
If the corner's angle is <=90 degrees then the possible range is limited.
if is the 'overlap' of the two possible solutions.
If its > 90 degrees the range is 'x' set off from the corner vertex itself [of course only the full range applies if the quads angles are 90 degrees]
You only need to test one 'corner'.
You take a series of pairs of points which fall within the two 'overlap' zones on the two edges sharing that corner's vertex - which of course must also be exactly 'x' apart when measured at the angle.
of an inscribed rectangle.
To do that we need to project a line from the two end vertices, at a vector that is transformed to be perpendicular to that line [x], and check if it intersects with the lines of the other two edges [i.e. those which are not shared the 'corner']; and where it does, if that intersected point is between the two ends of the tested line, and then of the length of the two tested vectors from each of the x.vertex.position to the hit.point is the same length, then the two long sides of the rectangle would be corrected so we have a match.
To minimize the number of tests the two corners could be compared and the overlap lengths compared - the shortest set then have the fewest tests...
Now potentially there is a whole series of solutions for 'x' in the minimum corner's zone set that would fit an inscribed rectangle into the quad...
Now to code it... -
I worked out an analytic geometry solution using the formulas for the distance between two points and for the intersection point of two given lines. Solving is "just" a matter of algebra. However, the remaining difficulty is that the math formulation covers various configurations that have no real-value solution (e.g. attached image) and it is difficult (or at least confusing) to weed these out of the formulas.
-
@slbaumgartner said:
I worked out an analytic geometry solution using the formulas for the distance between two points and for the intersection point of two given lines. Solving is "just" a matter of algebra. However, the remaining difficulty is that the math formulation covers various configurations that have no real-value solution (e.g. attached image) and it is difficult (or at least confusing) to weed these out of the formulas.
[attachment=1:2acewcov]<!-- ia1 -->Screen Shot 2014-12-02 at 9.43.20 AM.png<!-- ia1 -->[/attachment:2acewcov]
Advertisement