mirror of
https://github.com/Ed94/HandmadeHero.git
synced 2025-07-01 11:21:05 -07:00
Day 44 complete
This commit is contained in:
@ -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 };
|
||||
|
@ -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 };
|
||||
|
Reference in New Issue
Block a user