Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you assume a and b are the opposite corners of a rectangle</p> <pre><code>a = (xa, ya) b = (xb, yb) </code></pre> <p>then the top right rectangle point is <code>c1 = (max(xa,xb), max(ya,yb))</code> and the bottom left rectangle point is <code>c2 = (min(xa,xb), min(ya,yb))</code></p> <p>Assuming that <code>xa != xb</code> and <code>ya != yb</code></p> <pre><code> (xa, ya) A C1 (max(xa, xb), max(ya, yb)) o----------o |\ | | \ | | \ | | \ | | \ | | \ | | \ | | \ | | \ | o----------o (min(xa, xb), min(ya, yb)) C2 B (xb, yb) </code></pre> <p>If your diagonal is going the other way (to test this see if xa > xb) you need to swap min for max on the x</p> <pre><code>(min(xa, xb), max(ya, yb)) C3 A' o----------o | /| | / | | / | | / | | / | | / | | / | | / | | / | o----------o B' C4 (max(xa, xb), min(ya, yb)) </code></pre> <p>And if you're interested, the full set of solutions actually lies on the circle:</p> <p><img src="https://i.stack.imgur.com/PY9qO.png" alt="Set of solutions"></p> <p>To compute this, suppose we have two points <code>A = (xa, ya)</code> and <code>B = (xb, yb)</code>. Then the center point of this circle is <code>c = (0.5 (xa + xb), 0.5 (ya + yb))</code> - just the midpoint of the A and B. The radius of the circle is <code>r = sqrt( (xb - xa)^2 + (yb - ya)^2) / 2</code> - using pythagoras' theorem to get the length of the line and halving it. Then any point on the circle can be defined by <code>p = c + (rcos(u), rsin (u))</code> for some angle <code>u</code>. There are 2 angles which give you the points <code>p = A</code> and <code>p = B</code> so these values of <code>u</code> are not good solutions. You can write out the equation and solve it for these 2 points to give you the values of u which you cannot use.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload