How to implement rotation of a two-dimensional vector by 45 degrees, found solutions for 90, 180, 270. Such rotation can be realized only through the rotation matrix?

Another question regarding the further use of vector elements

```
int E;
cout & lt; & lt; "Input E";
cin & gt; & gt; E;
for (int y = 0; y & lt; col; ++ y)
{
if ((array [y] [y] == (min - E)) || (array [y] [y] == (min + E)))
{
cout & lt; & lt; "Element #" & lt; & lt; y + 1 & lt; & lt; ": match";
}
else {
cout & lt; & lt; "Element #" & lt; & lt; y + 1 & lt; & lt; ": not match";
}
}
```

In this case, the values are simply checked for matches with the condition (which is logical), but how to implement that the values that are suitable were used for further calculations?

## Answer 1, authority 100%

To rotate the 2D vector `(x, y) `

by the angle `a `

, you need to do the following calculations (note that `a `

here is measured in radians, not degrees):

```
cs = cos (a);
sn = sin (a);
rx = x * cs - y * sn;
ry = x * sn + y * cs;
```

Accordingly, in the case of a 45 degree rotation, the sine and cosine are `sqrt (2) / 2 `

, so the resulting vector `(rx, ry) `

can be found like this:

```
cs = sn = sqrt (2) / 2;
rx = x * cs - y * sn;
ry = x * sn + y * cs;
```

It is extremely difficult to answer your second question about the use in further calculations, because it is not clear what it consists of. Perhaps you want to add values that match the conditions to a list so that you can process them later. Explain what exactly is needed here.

## Answer 2, authority 33%

There are 2 ways to filter out unnecessary elements: