I'm trying to rotate vertices around some point in 2D. I found @Rabbid76 solution here https://stackoverflow.com/a/48156351/776388 but I need to rotate around z-vector.
Asked
Active
Viewed 942 times
1
-
Read about [How to use Pivot Point in Transformations](https://stackoverflow.com/questions/56804658/how-to-use-pivot-point-in-transformations/56806370#56806370) – Rabbid76 May 25 '20 at 08:56
1 Answers
2
I have found a solution
vec2 rotate(vec2 point, float degree, vec2 pivot)
{
float radAngle = -radians(degree);// "-" - clockwise
float x = point.x;
float y = point.y;
float rX = pivot.x + (x - pivot.x) * cos(radAngle) - (y - pivot.y) * sin(radAngle);
float rY = pivot.y + (x - pivot.x) * sin(radAngle) + (y - pivot.y) * cos(radAngle);
return vec2(rX, rY);
}

iscariot
- 434
- 7
- 14