Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
qwt_math.cpp
1/******************************************************************************
2 * Qwt Widget Library
3 * Copyright (C) 1997 Josef Wilgen
4 * Copyright (C) 2002 Uwe Rathmann
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the Qwt License, Version 1.0
8 *****************************************************************************/
9
10#include "qwt_math.h"
11#if QT_VERSION >= 0x050a00
12#include <qrandom.h>
13#endif
14
20double qwtNormalizeRadians( double radians )
21{
22 double a = std::fmod( radians, 2.0 * M_PI );
23 if ( a < 0.0 )
24 a += 2.0 * M_PI;
25
26 return a;
27
28}
29
35double qwtNormalizeDegrees( double degrees )
36{
37 double a = std::fmod( degrees, 360.0 );
38 if ( a < 0.0 )
39 a += 360.0;
40
41 return a;
42}
43
48quint32 qwtRand()
49{
50#if QT_VERSION >= 0x050a00
51 return QRandomGenerator::global()->generate();
52#else
53 return static_cast< quint32 >( qrand() ); // [0, RAND_MAX ]
54#endif
55}