diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-09 18:20:00 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2020-12-09 18:20:00 -0500 |
commit | cfe41fdfebe0913eeac99f8ac78ec52d5e00cc84 (patch) | |
tree | e5b8f6ecd303d3a7d8d83c7c7ec9cc542f6458f2 /math.cpp | |
parent | d642936e4c666ca316d9e855e4e4711076c99f33 (diff) |
moving platforms in editor
Diffstat (limited to 'math.cpp')
-rw-r--r-- | math.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -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; |