OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [torture/] [pr45393.C] - Blame information for rev 715

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
// { dg-do compile }
2
 
3
class FloatPoint;
4
class Path {
5
public:
6
    ~Path();
7
    void moveTo(const FloatPoint&);
8
    static void createEllipse(const FloatPoint& center, float rx, float ry);
9
};
10
extern "C" {
11
    extern float cosf (float);
12
    extern float sinf (float);
13
}
14
const float piFloat = static_cast(3.14159265358979323846);
15
class FloatPoint {
16
public:
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
};
22
void 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(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
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.