1.1 --- a/misc.cpp Tue Sep 05 09:47:14 2006 +0000
1.2 +++ b/misc.cpp Fri Dec 08 20:18:58 2006 +0000
1.3 @@ -11,13 +11,25 @@
1.4 return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
1.5 }
1.6
1.7 +QString qpointfToString (const QPointF &p)
1.8 +{
1.9 +// FIXME check this QT4
1.10 + return "(" + QString("%1").arg(p.x()) +","+ QString ("%1").arg (p.y()) +")";
1.11 +}
1.12 +
1.13 ostream &operator<< (ostream &stream, QPoint const &p)
1.14 {
1.15 stream << "("<<p.x()<<","<<p.y()<<")";
1.16 return stream;
1.17 }
1.18
1.19 -float getAngle(const QPoint &p)
1.20 +ostream &operator<< (ostream &stream, QPointF const &p)
1.21 +{
1.22 + stream << "("<<p.x()<<","<<p.y()<<")";
1.23 + return stream;
1.24 +}
1.25 +
1.26 +qreal getAngle(const QPointF &p)
1.27 {
1.28 // Calculate angle of vector to y-axis
1.29 if (p.y()==0)
1.30 @@ -29,24 +41,24 @@
1.31 } else
1.32 {
1.33 if (p.y()>0)
1.34 - return (float)(M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
1.35 + return (qreal)(M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
1.36 else
1.37 if (p.x()<0)
1.38 - return (float)( 2*M_PI - atan ( (double)(p.x()) / (double)(p.y()) ) );
1.39 + return (qreal)( 2*M_PI - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
1.40 else
1.41 - return (float)( - atan ( (double)(p.x()) / (double)(p.y()) ) );
1.42 + return (qreal)( - atan ( (qreal)(p.x()) / (qreal)(p.y()) ) );
1.43 }
1.44 }
1.45
1.46 -QPoint normalise(const QPoint &p)
1.47 +QPointF normalise(const QPointF &p)
1.48 {
1.49 // Calculate normalised position (fixed length)
1.50
1.51 - double px=p.x();
1.52 - double py=p.y();
1.53 - double x;
1.54 - double y;
1.55 - double r=150;
1.56 + qreal px=p.x();
1.57 + qreal py=p.y();
1.58 + qreal x;
1.59 + qreal y;
1.60 + qreal r=150;
1.61
1.62 if (px==0)
1.63 {
1.64 @@ -57,8 +69,8 @@
1.65 y=-r;
1.66 } else
1.67 {
1.68 - double sign;
1.69 - double a;
1.70 + qreal sign;
1.71 + qreal a;
1.72 if (px>0)
1.73 sign=1;
1.74 else
1.75 @@ -87,7 +99,8 @@
1.76 return r;
1.77 }
1.78
1.79 -int max(int a, int b)
1.80 +
1.81 +qreal max(qreal a, qreal b)
1.82 {
1.83 if (a>b)
1.84 return a;