blob: c30bb6a50d93a544a1d29371b6166ff972939fdc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#include "cru/platform/Matrix.h"
#include "cru/platform/graphics/direct2d/ConvertUtil.h"
#include <catch2/catch_test_macros.hpp>
#include "catch2/catch_approx.hpp"
using Catch::Approx;
using cru::platform::Matrix;
using cru::platform::graphics::direct2d::Convert;
TEST_CASE("MatrixConvert Rotation", "[matrix]") {
auto matrix = Convert(Matrix::Rotation(90));
auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix);
auto p = m.TransformPoint({1, 1});
REQUIRE(p.x == Approx(-1));
REQUIRE(p.y == Approx(1));
}
TEST_CASE("MatrixConvert RotationAndTranslation", "[matrix]") {
auto matrix = Convert(Matrix::Rotation(90) * Matrix::Translation(1, 1));
auto m = *D2D1::Matrix3x2F::ReinterpretBaseType(&matrix);
auto p = m.TransformPoint({1, 1});
REQUIRE(p.x == Approx(0));
REQUIRE(p.y == Approx(2));
}
|