From a32157049d860c4c9c6ffb0df6c3cdbf53e4ef1d Mon Sep 17 00:00:00 2001 From: Matthew Kosarek Date: Mon, 26 Apr 2021 20:51:09 -0400 Subject: Getting started on rectangle collisions --- frontend/shared_cpp/mathlib.cpp | 11 +++++++++++ frontend/shared_cpp/mathlib.h | 4 ++++ 2 files changed, 15 insertions(+) create mode 100644 frontend/shared_cpp/mathlib.cpp (limited to 'frontend/shared_cpp') diff --git a/frontend/shared_cpp/mathlib.cpp b/frontend/shared_cpp/mathlib.cpp new file mode 100644 index 0000000..8222d00 --- /dev/null +++ b/frontend/shared_cpp/mathlib.cpp @@ -0,0 +1,11 @@ +#include "mathlib.h" +#include + +Vector2 getRandomNormalVector2() { + Vector2 retval = { + static_cast(rand()) / static_cast(RAND_MAX), + static_cast(rand()) / static_cast(RAND_MAX) + }; + + return retval.normalize(); +} diff --git a/frontend/shared_cpp/mathlib.h b/frontend/shared_cpp/mathlib.h index a08ec39..3ed61cd 100644 --- a/frontend/shared_cpp/mathlib.h +++ b/frontend/shared_cpp/mathlib.h @@ -110,6 +110,10 @@ struct Vector4 { float scale = 1.f / 255.f; return { r * scale, g * scale, b * scale, a * scale }; } + + Vector4 toNormalizedColor() { + return fromColor(x, y, z, w); + } }; struct Mat4x4 { -- cgit v1.2.1