1 (edited by KChris 2017-08-13 00:08:00)

Topic: Changing velocity's angle

-deleted-

Lazy dev

2

Re: Changing velocity's angle

new_x = x*cos(phi) - y*sin(phi);
new_y = x*sin(phi)  + y*cos(phi);

(As far as I can remember there is a rotation function in the code, isn't it?)

3 (edited by KChris 2017-08-13 00:07:53)

Re: Changing velocity's angle

-deleted-

Lazy dev

4

Re: Changing velocity's angle

in source exists 3 implementations of "Rotate" method:

editor.cpp

static void Rotate(CPoint *pCenter, CPoint *pPoint, float Rotation)
{
    int x = pPoint->x - pCenter->x;
    int y = pPoint->y - pCenter->y;
    pPoint->x = (int)(x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x);
    pPoint->y = (int)(x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y);
}

render_map.cpp

static void Rotate(const CPoint *pCenter, CPoint *pPoint, float Rotation)
{
    int x = pPoint->x - pCenter->x;
    int y = pPoint->y - pCenter->y;
    pPoint->x = (int)(x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x);
    pPoint->y = (int)(x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y);
}

layer_quads.cpp

void Rotate(vec2 *pCenter, vec2 *pPoint, float Rotation)
{
    float x = pPoint->x - pCenter->x;
    float y = pPoint->y - pCenter->y;
    pPoint->x = x * cosf(Rotation) - y * sinf(Rotation) + pCenter->x;
    pPoint->y = x * sinf(Rotation) + y * cosf(Rotation) + pCenter->y;
}

5 (edited by KChris 2017-08-13 00:07:45)

Re: Changing velocity's angle

-deleted-

Lazy dev

6

Re: Changing velocity's angle

Yeah, it's weird. I would say that its location should be "vmath.h"...  and why use CPoint and not vec3 ??  xD