So currently im making a game in raylib library in C
I was expecting to rotate the rectangle but what really did happen the rectangle was being rotated using rectanglepro function but collision were'nt defined on it so it failed.
I am using the following code but it doesn't work:
RotatedVector = Vector2Rotate(Vector2Normalize(Center), angle * DEG2RAD);
Where as Vector2Rotate
is function of raymath.h
defined as:
RMAPI Vector2 Vector2Rotate(Vector2 v, float angle)
{
Vector2 result = { 0 };
float cosres = cosf(angle);
float sinres = sinf(angle);
result.x = v.x * cosres - v.y * sinres;
result.y = v.x * sinres + v.y * cosres;
return result;
}
Vector2Normalize
is defined as
RMAPI Vector2 Vector2Normalize(Vector2 v)
{
Vector2 result = { 0 };
float length = sqrtf((v.x * v.x) + (v.y * v.y));
if (length > 0)
{
float ilength = 1.0f / length;
result.x = v.x * ilength;
result.y = v.y * ilength;
}
return result;
}