summaryrefslogtreecommitdiff
path: root/math.cpp
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2020-12-09 18:20:00 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2020-12-09 18:20:00 -0500
commitcfe41fdfebe0913eeac99f8ac78ec52d5e00cc84 (patch)
treee5b8f6ecd303d3a7d8d83c7c7ec9cc542f6458f2 /math.cpp
parentd642936e4c666ca316d9e855e4e4711076c99f33 (diff)
moving platforms in editor
Diffstat (limited to 'math.cpp')
-rw-r--r--math.cpp9
1 files changed, 9 insertions, 0 deletions
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;