source: ntrip/trunk/BNC/qwt/qwt_math.cpp@ 8321

Last change on this file since 8321 was 8127, checked in by stoecker, 8 years ago

update qwt and qwtpolar, many QT5 fixes (unfinished)

File size: 1.6 KB
Line 
1/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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
12/*!
13 \brief Find the smallest value in an array
14 \param array Pointer to an array
15 \param size Array size
16*/
17double qwtGetMin( const double *array, int size )
18{
19 if ( size <= 0 )
20 return 0.0;
21
22 double rv = array[0];
23 for ( int i = 1; i < size; i++ )
24 rv = qMin( rv, array[i] );
25
26 return rv;
27}
28
29
30/*!
31 \brief Find the largest value in an array
32 \param array Pointer to an array
33 \param size Array size
34*/
35double qwtGetMax( const double *array, int size )
36{
37 if ( size <= 0 )
38 return 0.0;
39
40 double rv = array[0];
41 for ( int i = 1; i < size; i++ )
42 rv = qMax( rv, array[i] );
43
44 return rv;
45}
46
47/*!
48 \brief Normalize an angle to be int the range [0.0, 2 * PI[
49 \param radians Angle in radians
50 \return Normalized angle in radians
51*/
52double qwtNormalizeRadians( double radians )
53{
54 double a = ::fmod( radians, 2.0 * M_PI );
55 if ( a < 0.0 )
56 a += 2.0 * M_PI;
57
58 return a;
59
60}
61
62/*!
63 \brief Normalize an angle to be int the range [0.0, 360.0[
64 \param radians Angle in degrees
65 \return Normalized angle in degrees
66*/
67double qwtNormalizeDegrees( double degrees )
68{
69 double a = ::fmod( degrees, 360.0 );
70 if ( a < 0.0 )
71 a += 360.0;
72
73 return a;
74}
Note: See TracBrowser for help on using the repository browser.