Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add a test for rotating a 2D vector

  • Loading branch information...
commit d41c7b01d827570fa74336d62785e8d7d172f07b 1 parent 2e62995
@Kazade authored
Showing with 19 additions and 1 deletion.
  1. +0 −1  tests/test_ray2.cpp
  2. +19 −0 tests/test_vec2.cpp
View
1  tests/test_ray2.cpp
@@ -68,4 +68,3 @@ TEST(test_triangle_intersection) {
CHECK_CLOSE(0.0f, normal.x, 0.001f);
CHECK_CLOSE(1.0f, normal.y, 0.001f);
}
-
View
19 tests/test_vec2.cpp
@@ -28,3 +28,22 @@ TEST(test_degrees_between) {
CHECK_CLOSE(90.0f, kmVec2DegreesBetween(&v1, &v2), 0.001f);
CHECK_CLOSE(-90.0f, kmVec2DegreesBetween(&v2, &v1), 0.001f);
}
+
+TEST(test_vec2_rotate_by) {
+ kmVec2 res;
+ kmVec2RotateBy(&res, &KM_VEC2_POS_Y, 90, &KM_VEC2_ZERO);
+
+ CHECK_CLOSE(-1, res.x, 0.001f);
+ CHECK_CLOSE(0, res.y, 0.001f);
+
+ kmVec2RotateBy(&res, &KM_VEC2_POS_Y, -90, &KM_VEC2_ZERO);
+
+ CHECK_CLOSE(1, res.x, 0.001f);
+ CHECK_CLOSE(0, res.y, 0.001f);
+
+ kmVec2RotateBy(&res, &KM_VEC2_POS_Y, 180, &KM_VEC2_ZERO);
+
+ CHECK_CLOSE(0, res.x, 0.001f);
+ CHECK_CLOSE(-1, res.y, 0.001f);
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.