Note that there are some explanatory texts on larger screens.

plurals
  1. PO2d rotation on set of points causes skewing distortion
    primarykey
    data
    text
    <p>I'm writing an application in OpenGL (though I don't think this problem is related to that). I have some 2d point set data that I need to rotate. It later gets projected into 3d.</p> <p>I apply my rotation using this formula:</p> <pre><code>x' = x cos f - y sin f y' = y cos f + x sin f </code></pre> <p>Where 'f' is the angle. When I rotate the point set, the result is skewed. The severity of the effect varies with the angle. </p> <p>It's hard to describe so I have pictures; The red things are some simple geometry. The 2d point sets are the vertices for the white polylines you see around them. The first picture shows the undistorted pointsets, and the second picture shows them after rotation. It's not just skew that's occuring with the rotation; sometimes it seems like displacement occurs as well.</p> <p><img src="https://i.stack.imgur.com/eZSq5.png" alt="enter image description here"></p> <p><img src="https://i.stack.imgur.com/VNhux.png" alt="enter image description here"></p> <p>The code itself is trivial:</p> <pre><code>double cosTheta = cos(2.4); double sinTheta = sin(2.4); CalcSimplePolyCentroid(listHullVx,xlate); for(size_t j=0; j &lt; listHullVx.size(); j++) { // translate listHullVx[j] = listHullVx[j] - xlate; // rotate double xPrev = listHullVx[j].x; double yPrev = listHullVx[j].y; listHullVx[j].x = ((xPrev*cosTheta) - (yPrev*sinTheta)); listHullVx[j].y = ((yPrev*cosTheta) + (xPrev*sinTheta)); // translate listHullVx[j] = listHullVx[j] + xlate; } </code></pre> <p>If I comment out the code under '//rotate' above, the output of the application is the first image. And adding it back in gives the second image. There's literally nothing else that's going on (afaik).</p> <p>The data types being used are all doubles so I don't think its a precision issue. Does anyone have any idea why rotation would cause skewing like the above pictures show?</p> <p>EDIT filipe's comment below was correct. This probably has nothing to do with the rotation and I hadn't provided enough information for the problem;</p> <p>The geometry I've shown in the pictures represents buildings. They're generated from lon/lat map coordinates. In the point data I use to do the transform, I forgot to use an actual projection to cartesian coordinate space and just mapped x->lon, y->lat, and I think this is the reason I'm seeing the distortion. I'm going to request that this question be deleted since I don't think it'll be useful to anyone else.</p>
    singulars
    1. This table or related slice is empty.
    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