Day 44 complete

This commit is contained in:
2023-11-05 23:36:30 -05:00
parent e1a481f4f6
commit bcfbb94df7
6 changed files with 291 additions and 108 deletions

View File

@ -60,6 +60,12 @@ inline Pos2_f32 normalize( Pos2_f32 v )
return result;
}
inline f32 scalar_product( Pos2_f32 a, Pos2_f32 b )
{
f32 result = a.x * b.x + a.y * b.y;
return result;
}
inline Pos2_f32 operator-( Pos2_f32 v )
{
Pos2_f32 result { -v.x, -v.y };
@ -189,6 +195,12 @@ inline Vel2_f32 normalize( Vel2_f32 v )
return result;
}
inline f32 scalar_product( Vel2_f32 a, Vel2_f32 b )
{
f32 result = a.x * b.x + a.y * b.y;
return result;
}
inline Vel2_f32 operator-( Vel2_f32 v )
{
Vel2_f32 result { -v.x, -v.y };
@ -308,6 +320,12 @@ inline Accel2_f32 normalize( Accel2_f32 v )
return result;
}
inline f32 scalar_product( Accel2_f32 a, Accel2_f32 b )
{
f32 result = a.x * b.x + a.y * b.y;
return result;
}
inline Accel2_f32 operator-( Accel2_f32 v )
{
Accel2_f32 result { -v.x, -v.y };

View File

@ -49,6 +49,12 @@ inline Vec2_f32 normalize( Vec2_f32 v )
return result;
}
inline f32 scalar_product( Vec2_f32 a, Vec2_f32 b )
{
f32 result = a.x * b.x + a.y * b.y;
return result;
}
inline Vec2_f32 operator-( Vec2_f32 v )
{
Vec2_f32 result { -v.x, -v.y };
@ -145,18 +151,6 @@ inline s32 magnitude( Vec2_s32 v )
return result;
}
inline Vec2_s32 normalize( Vec2_s32 v )
{
s32 square_size = v.x * v.x + v.y * v.y;
if ( square_size < scast( s32, 1e-4 ) )
{
return Zero( Vec2_s32 );
}
s32 mag = sqrt( square_size );
Vec2_s32 result { v.x / mag, v.y / mag };
return result;
}
inline Vec2_s32 operator-( Vec2_s32 v )
{
Vec2_s32 result { -v.x, -v.y };