1// { dg-do compile } 2 3class FloatPoint; 4class Path { 5public: 6 ~Path(); 7 void moveTo(const FloatPoint&); 8 static void createEllipse(const FloatPoint& center, float rx, float ry); 9}; 10extern "C" { 11 extern float cosf (float); 12 extern float sinf (float); 13} 14const float piFloat = static_cast<float>(3.14159265358979323846); 15class FloatPoint { 16public: 17 FloatPoint(float x, float y) : m_x(x), m_y(y) { } 18 float x() const; 19 float y() const; 20 float m_x, m_y; 21}; 22void Path::createEllipse(const FloatPoint& center, float rx, float ry) 23{ 24 float cx = center.x(); 25 float cy = center.y(); 26 Path path; 27 float x = cx; 28 float y = cy; 29 unsigned step = 0, num = 100; 30 while (1) { 31 float angle = static_cast<float>(step) / num * 2.0f * piFloat; 32 x = cx + cosf(angle) * rx; 33 y = cy + sinf(angle) * ry; 34 step++; 35 if (step == 1) 36 path.moveTo(FloatPoint(x, y)); 37 } 38} 39