Skip to content
Browse files

Complex class

  • Loading branch information...
1 parent 06dd37d commit fe449cceb9d2456279ed854a9cafde849f01f5d3 @grahamboree committed
Showing with 18 additions and 1 deletion.
  1. +17 −1 Source/cppimage/CxDefines.h
  2. +1 −0 cppimage_tests/TestCxDefines.h
View
18 Source/cppimage/CxDefines.h
@@ -235,7 +235,22 @@ namespace CppImage
{
return (b * 117 + g * 601 + r * 306) >> 10;
}
-
+
+#if 1
+ class Complex
+ {
+ public:
+ inline Complex(double inX, double inY) : mX(inX), mY(inY) {}
+ inline double Abs() const { return sqrt(mX * mX + mY * mY); }
+ private:
+ double mX;
+ double mY;
+ };
+
+ // Compatibility...
+ typedef Complex _complex;
+ static inline double _cabs(const _complex& c) { return c.Abs(); }
+#else
struct _complex
{
double x;
@@ -246,6 +261,7 @@ namespace CppImage
# define MACRO__cabs(c) sqrt(c.x*c.x+c.y*c.y)
#endif
static inline double _cabs(const _complex& c) { return sqrt(c.x * c.x + c.y * c.y); }
+#endif
}
using namespace CppImage;
View
1 cppimage_tests/TestCxDefines.h
@@ -39,6 +39,7 @@ inline void TestCxDefines::testRGB()
TEST_ASSERT(GetRValue(red) == 255);
TEST_ASSERT(GetGValue(green) == 255);
TEST_ASSERT(GetBValue(blue) == 255);
+ std::cout << "blue = " << (unsigned short)(MACRO_GetBValue(blue)) << std::endl;
COLORREF someColor = RGB(1,2,3);
TEST_ASSERT(GetRValue(someColor) == MACRO_GetRValue(someColor));

0 comments on commit fe449cc

Please sign in to comment.
Something went wrong with that request. Please try again.