|
|
|
@ -46,6 +46,7 @@ class ComplexTest: public Corrade::TestSuite::Tester { |
|
|
|
void invertedNormalized(); |
|
|
|
void invertedNormalized(); |
|
|
|
|
|
|
|
|
|
|
|
void angle(); |
|
|
|
void angle(); |
|
|
|
|
|
|
|
void rotation(); |
|
|
|
|
|
|
|
|
|
|
|
void debug(); |
|
|
|
void debug(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -72,10 +73,12 @@ ComplexTest::ComplexTest() { |
|
|
|
&ComplexTest::invertedNormalized, |
|
|
|
&ComplexTest::invertedNormalized, |
|
|
|
|
|
|
|
|
|
|
|
&ComplexTest::angle, |
|
|
|
&ComplexTest::angle, |
|
|
|
|
|
|
|
&ComplexTest::rotation, |
|
|
|
|
|
|
|
|
|
|
|
&ComplexTest::debug); |
|
|
|
&ComplexTest::debug); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef Math::Deg<float> Deg; |
|
|
|
typedef Math::Rad<float> Rad; |
|
|
|
typedef Math::Rad<float> Rad; |
|
|
|
typedef Math::Complex<float> Complex; |
|
|
|
typedef Math::Complex<float> Complex; |
|
|
|
typedef Math::Vector2<float> Vector2; |
|
|
|
typedef Math::Vector2<float> Vector2; |
|
|
|
@ -228,6 +231,20 @@ void ComplexTest::angle() { |
|
|
|
CORRADE_COMPARE(angle, Rad(2.933128f)); |
|
|
|
CORRADE_COMPARE(angle, Rad(2.933128f)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ComplexTest::rotation() { |
|
|
|
|
|
|
|
Complex a = Complex::rotation(Deg(120.0f)); |
|
|
|
|
|
|
|
CORRADE_COMPARE(a, Complex(-0.5f, 0.8660254f)); |
|
|
|
|
|
|
|
CORRADE_COMPARE_AS(a.rotationAngle(), Deg(120.0f), Rad); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Verify negative angle */ |
|
|
|
|
|
|
|
Complex b = Complex::rotation(Deg(-240.0f)); |
|
|
|
|
|
|
|
CORRADE_COMPARE(b, Complex(-0.5f, 0.8660254f)); |
|
|
|
|
|
|
|
CORRADE_COMPARE_AS(b.rotationAngle(), Deg(120.0f), Rad); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Default-constructed complex number has zero angle */ |
|
|
|
|
|
|
|
CORRADE_COMPARE_AS(Complex().rotationAngle(), Deg(0.0f), Rad); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void ComplexTest::debug() { |
|
|
|
void ComplexTest::debug() { |
|
|
|
std::ostringstream o; |
|
|
|
std::ostringstream o; |
|
|
|
|
|
|
|
|
|
|
|
|