Topic: Changing velocity's angle
-deleted-
You are not logged in. Please login or register.
Teeworlds Forum → Modifications → Changing velocity's angle
-deleted-
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?)
-deleted-
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;
}
-deleted-
Yeah, it's weird. I would say that its location should be "vmath.h"... and why use CPoint and not vec3 ?? xD
Teeworlds Forum → Modifications → Changing velocity's angle
Powered by PunBB, supported by Informer Technologies, Inc.
Currently installed 3 official extensions. Copyright © 2003–2009 PunBB.