From cfe41fdfebe0913eeac99f8ac78ec52d5e00cc84 Mon Sep 17 00:00:00 2001 From: Leo Tenenbaum Date: Wed, 9 Dec 2020 18:20:00 -0500 Subject: moving platforms in editor --- math.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'math.cpp') diff --git a/math.cpp b/math.cpp index 060eb0d..534438a 100644 --- a/math.cpp +++ b/math.cpp @@ -155,6 +155,15 @@ static v2 v2_lerp(float x, v2 a, v2 b) { return V2(lerpf(x, a.x, b.x), lerpf(x, a.y, b.y)); } +// rotate v theta radians counterclockwise +static v2 v2_rotate(v2 v, float theta) { + float c = cosf(theta), s = sinf(theta); + return V2( + c * v.x - s * v.y, + s * v.x + c * v.y + ); +} + static v2 v2_normalize(v2 v) { float len = v2_len(v); float mul = len == 0.0f ? 1.0f : 1.0f/len; -- cgit v1.2.3