简体   繁体   中英

Rotating a triangle around a point of origin

Having trouble rotating a triangle around a center point, triangle warps and exceeds it's usual size when trying to rotate.

Here's what I'm working with

     x1r = ((x1 - s.x) * cos(radians)) - ((s.y - y1) * sin(radians)) + s.x;
     y1r = ((s.y - y1) * cos(radians)) + ((x1 - s.x) * sin(radians)) + s.y;
     x2r = ((x2 - s.x) * cos(radians)) - ((s.y - y2) * sin(radians)) + s.x;
     y2r = ((s.y - y2) * cos(radians)) + ((x2 - s.x) * sin(radians)) + s.y;
     x3r = ((x3 - s.x) * cos(radians)) - ((s.y - y3) * sin(radians)) + s.x;
     y3r = ((s.y - y3) * cos(radians)) + ((x3 - s.x) * sin(radians)) + s.y;

Any guidance would be much appreciated!

Incorrect formula used to rotate in the 3 points. Ref

//x1r = ((x1 - s.x) * cos(radians)) - ((s.y - y1) * sin(radians)) + s.x;
//y1r = ((s.y - y1) * cos(radians)) + ((x1 - s.x) * sin(radians)) + s.y;
  x1r = ((x1 - s.x) * cos(radians)) - ((y1 - s.y) * sin(radians)) + s.x;
  y1r = ((y1 - s.y) * cos(radians)) + ((x1 - s.x) * sin(radians)) + s.y;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM