Erik Ahlswede - 1 year ago 66

C++ Question

I am trying to rotate a vector around a certain point on the vector(in C++):

`1 2 3`

4 5 6

7 8 9

rotated around the point (1,1) (which is the "5") 90 degrees would result in:

`7 4 1`

8 5 2

9 6 3

Right now I am using:

`x = (x * cos(90)) - (y * sin(90))`

y = (y * cos(90)) + (x * sin(90))

But I don't want it rotated around (0,0)

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

As Mehrdad Afshari commented on Pesto's post, including the translation back into the original coordinate system would be:

```
x_rotated = ((x - x_origin) * cos(angle)) - ((y_origin - y) * sin(angle)) + x_origin
y_rotated = ((y_origin - y) * cos(angle)) - ((x - x_origin) * sin(angle)) + y_origin
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**