Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_math.h


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_math.h

    r4271 r8127  
    2424#endif
    2525
    26 #include <qpoint.h>
    2726#include <qmath.h>
    2827#include "qwt_global.h"
    2928
    30 #ifndef LOG10_2
    31 #define LOG10_2     0.30102999566398119802  /* log10(2) */
    32 #endif
    33 
    34 #ifndef LOG10_3
    35 #define LOG10_3     0.47712125471966243540  /* log10(3) */
    36 #endif
    37 
    38 #ifndef LOG10_5
    39 #define LOG10_5     0.69897000433601885749  /* log10(5) */
    40 #endif
    41 
    42 #ifndef M_2PI
    43 #define M_2PI       6.28318530717958623200  /* 2 pi */
     29#ifndef M_PI_2
     30// For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64
     31// when compiling with -std=c++11
     32#define M_PI_2 (1.57079632679489661923)
    4433#endif
    4534
    4635#ifndef LOG_MIN
    47 //! Mininum value for logarithmic scales
     36//! Minimum value for logarithmic scales
    4837#define LOG_MIN 1.0e-100
    4938#endif
     
    5443#endif
    5544
    56 #ifndef M_E
    57 #define M_E            2.7182818284590452354   /* e */
    58 #endif
    59 
    60 #ifndef M_LOG2E
    61 #define M_LOG2E 1.4426950408889634074   /* log_2 e */
    62 #endif
    63 
    64 #ifndef M_LOG10E
    65 #define M_LOG10E    0.43429448190325182765  /* log_10 e */
    66 #endif
    67 
    68 #ifndef M_LN2
    69 #define M_LN2       0.69314718055994530942  /* log_e 2 */
    70 #endif
    71 
    72 #ifndef M_LN10
    73 #define M_LN10         2.30258509299404568402  /* log_e 10 */
    74 #endif
    75 
    76 #ifndef M_PI
    77 #define M_PI        3.14159265358979323846  /* pi */
    78 #endif
    79 
    80 #ifndef M_PI_2
    81 #define M_PI_2      1.57079632679489661923  /* pi/2 */
    82 #endif
    83 
    84 #ifndef M_PI_4
    85 #define M_PI_4      0.78539816339744830962  /* pi/4 */
    86 #endif
    87 
    88 #ifndef M_1_PI
    89 #define M_1_PI      0.31830988618379067154  /* 1/pi */
    90 #endif
    91 
    92 #ifndef M_2_PI
    93 #define M_2_PI      0.63661977236758134308  /* 2/pi */
    94 #endif
    95 
    96 #ifndef M_2_SQRTPI
    97 #define M_2_SQRTPI  1.12837916709551257390  /* 2/sqrt(pi) */
    98 #endif
    99 
    100 #ifndef M_SQRT2
    101 #define M_SQRT2 1.41421356237309504880  /* sqrt(2) */
    102 #endif
    103 
    104 #ifndef M_SQRT1_2
    105 #define M_SQRT1_2   0.70710678118654752440  /* 1/sqrt(2) */
    106 #endif
    107 
    10845QWT_EXPORT double qwtGetMin( const double *array, int size );
    10946QWT_EXPORT double qwtGetMax( const double *array, int size );
     47
     48QWT_EXPORT double qwtNormalizeRadians( double radians );
     49QWT_EXPORT double qwtNormalizeDegrees( double degrees );
    11050
    11151/*!
     
    162102}
    163103
    164 //! Like qRound, but without converting the result to an int
    165 inline double qwtRoundF(double d)
    166 {
    167     return ::floor( d + 0.5 );
     104//! Approximation of arc tangent ( error below 0,005 radians )
     105inline double qwtFastAtan( double x )
     106{
     107    if ( x < -1.0 )
     108        return -M_PI_2 - x / ( x * x + 0.28 );
     109
     110    if ( x > 1.0 )
     111        return M_PI_2 - x / ( x * x + 0.28 );
     112
     113    return x / ( 1.0 + x * x * 0.28 );
    168114}
    169115
    170 //! Like qFloor, but without converting the result to an int
    171 inline double qwtFloorF(double d)
    172 {
    173     return ::floor( d );
     116//! Approximation of arc tangent ( error below 0,005 radians )
     117inline double qwtFastAtan2( double y, double x )
     118{
     119    if ( x > 0 )
     120        return qwtFastAtan( y / x );
     121
     122    if ( x < 0 )
     123    {
     124        const double d = qwtFastAtan( y / x );
     125        return ( y >= 0 ) ? d + M_PI : d - M_PI;
     126    }
     127
     128    if ( y < 0.0 )
     129        return -M_PI_2;
     130
     131    if ( y > 0.0 )
     132        return M_PI_2;
     133
     134    return 0.0;
    174135}
    175136
    176 //! Like qCeil, but without converting the result to an int
    177 inline double qwtCeilF(double d)
    178 {
    179     return ::ceil( d );
     137//! Translate degrees into radians
     138inline double qwtRadians( double degrees )
     139{
     140    return degrees * M_PI / 180.0;
     141}
     142
     143//! Translate radians into degrees
     144inline double qwtDegrees( double degrees )
     145{
     146    return degrees * 180.0 / M_PI;
    180147}
    181148
Note: See TracChangeset for help on using the changeset viewer.