Added QET::round() and QET::roundPoint().

git-svn-id: svn+ssh://svn.tuxfamily.org/svnroot/qet/qet/trunk@2057 bfdf4180-ca20-0410-9c96-a3a8aa849046
This commit is contained in:
xavier
2013-03-06 18:50:46 +00:00
parent 1e1cf8b1da
commit 62a59f5341
2 changed files with 17 additions and 0 deletions

View File

@@ -497,6 +497,21 @@ QString QET::pointerString(void *ptr) {
);
}
/**
Round \a x to the nearest multiple of the invert of \a epsilon.
For instance, epsilon = 10 will round to 1/10 = 0.1
*/
qreal QET::round(qreal x, qreal epsilon) {
return(int(x * epsilon) / epsilon);
}
/**
Round the coordinates of \a p to the nearest multiple of \a epsilon.
*/
QPointF QET::roundPoint(const QPointF &p, qreal epsilon) {
return(QPointF(QET::round(p.x(), epsilon), QET::round(p.y(), epsilon)));
}
/**
@param angle Un angle quelconque
@return l'angle passe en parametre, mais ramene entre -360.0 + 360.0 degres