Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If I understand your question right:</p> <pre><code>given: shape has corner (x1,y1), center (xc,yc) rotated shape has corner (x1',y1') after being rotated about center desired: how to map any point of the shape (x,y) -&gt; (x',y') by that same rotation </code></pre> <p>Here's the relevant equations:</p> <pre><code>(x'-xc) = Kc*(x-xc) - Ks*(y-yc) (y'-yc) = Ks*(x-xc) + Kc*(y-yc) </code></pre> <p>where <code>Kc=cos(theta)</code> and <code>Ks=sin(theta)</code> and <code>theta</code> is the angle of counterclockwise rotation. (to verify: if theta=0 this leaves the coordinates unchanged, otherwise if xc=yc=0, it maps (1,0) to (cos(theta),sin(theta)) and (0,1) to (-sin(theta), cos(theta)) . Caveat: this is for coordinate systems where (x,y)=(1,1) is in the upper right quadrant. For yours where it's in the lower right quadrant, theta would be the angle of clockwise rotation rather than counterclockwise rotation.)</p> <p>If you know the coordinates of your rectangle aligned with the x-y axes, xc would just be the average of the two x-coordinates and yc would just be the average of the two y-coordinates. (in your situation, it's xc=75,yc=85.)</p> <p>If you know theta, you now have enough information to calculate the new coordinates. If you don't know theta, you can solve for Kc, Ks. Here's the relevant calculations for your example:</p> <pre><code>(62-75) = Kc*(50-75) - Ks*(50-85) (40-85) = Ks*(50-75) + Kc*(50-85) -13 = -25*Kc + 35*Ks = -25*Kc + 35*Ks -45 = -25*Ks - 35*Kc = -35*Kc - 25*Ks </code></pre> <p>which is a <a href="http://en.wikipedia.org/wiki/System_of_linear_equations" rel="noreferrer">system of linear equations</a> that can be solved (exercise for the reader: in MATLAB it's:</p> <pre><code>[-25 35;-35 -25]\[-13;-45] </code></pre> <p>to yield, in this case, Kc=1.027, Ks=0.3622 which does NOT make sense (K<sup>2</sup> = Kc<sup>2</sup> + Ks<sup>2</sup> is supposed to equal 1 for a pure rotation; in this case it's K = 1.089) so it's not a pure rotation about the rectangle center, which is what your drawing indicates. Nor does it seem to be a pure rotation about the origin. To check, compare distances from the center of rotation before and after the rotation using the Pythagorean theorem, d<sup>2</sup> = deltax<sup>2</sup> + deltay<sup>2</sup>. (for rotation about xc=75,yc=85, distance before is 43.01, distance after is 46.84, the ratio is K=1.089; for rotation about the origin, distance before is 70.71, distance after is 73.78, ratio is 1.043. I could believe ratios of 1.01 or less would arise from coordinate rounding to integers, but this is clearly larger than a roundoff error)</p> <p>So there's some missing information here. How did you get the numbers (62,40)?</p> <p>That's the basic gist of the math behind rotations, however.</p> <p>edit: aha, I didn't realize they were estimates. (pretty close to being realistic, though!)</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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