qwt_point_polar.h
Go to the documentation of this file.
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 
11 #ifndef QWT_POINT_POLAR_H
12 #define QWT_POINT_POLAR_H
13 
14 #include "qwt_global.h"
15 #include "qwt_math.h"
16 
17 #include <qpoint.h>
18 #include <qmetatype.h>
19 #include <qmath.h>
20 
29 {
30  public:
31  QwtPointPolar();
32  QwtPointPolar( double azimuth, double radius );
33  QwtPointPolar( const QPointF& );
34 
35  void setPoint( const QPointF& );
36  QPointF toPoint() const;
37 
38  bool isValid() const;
39  bool isNull() const;
40 
41  double radius() const;
42  double azimuth() const;
43 
44  double& rRadius();
45  double& rAzimuth();
46 
47  void setRadius( double );
48  void setAzimuth( double );
49 
50  bool operator==( const QwtPointPolar& ) const;
51  bool operator!=( const QwtPointPolar& ) const;
52 
53  QwtPointPolar normalized() const;
54 
55  private:
56  double m_azimuth;
57  double m_radius;
58 };
59 
60 Q_DECLARE_TYPEINFO( QwtPointPolar, Q_MOVABLE_TYPE );
61 Q_DECLARE_METATYPE( QwtPointPolar )
62 
63 #ifndef QT_NO_DEBUG_STREAM
64 QWT_EXPORT QDebug operator<<( QDebug, const QwtPointPolar& );
65 #endif
66 
72  : m_azimuth( 0.0 )
73  , m_radius( 0.0 )
74 {
75 }
76 
83 inline QwtPointPolar::QwtPointPolar( double azimuth, double radius )
84  : m_azimuth( azimuth )
85  , m_radius( radius )
86 {
87 }
88 
90 inline bool QwtPointPolar::isValid() const
91 {
92  return m_radius >= 0.0;
93 }
94 
96 inline bool QwtPointPolar::isNull() const
97 {
98  return m_radius == 0.0;
99 }
100 
102 inline double QwtPointPolar::radius() const
103 {
104  return m_radius;
105 }
106 
108 inline double QwtPointPolar::azimuth() const
109 {
110  return m_azimuth;
111 }
112 
114 inline double& QwtPointPolar::rRadius()
115 {
116  return m_radius;
117 }
118 
120 inline double& QwtPointPolar::rAzimuth()
121 {
122  return m_azimuth;
123 }
124 
126 inline void QwtPointPolar::setRadius( double radius )
127 {
128  m_radius = radius;
129 }
130 
132 inline void QwtPointPolar::setAzimuth( double azimuth )
133 {
134  m_azimuth = azimuth;
135 }
136 
137 inline QPoint qwtPolar2Pos( const QPoint& pole,
138  double radius, double angle )
139 {
140  const double x = pole.x() + radius * std::cos( angle );
141  const double y = pole.y() - radius * std::sin( angle );
142 
143  return QPoint( qRound( x ), qRound( y ) );
144 }
145 
146 inline QPoint qwtDegree2Pos( const QPoint& pole,
147  double radius, double angle )
148 {
149  return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
150 }
151 
152 inline QPointF qwtPolar2Pos( const QPointF& pole,
153  double radius, double angle )
154 {
155  const double x = pole.x() + radius * std::cos( angle );
156  const double y = pole.y() - radius * std::sin( angle );
157 
158  return QPointF( x, y);
159 }
160 
161 inline QPointF qwtDegree2Pos( const QPointF& pole,
162  double radius, double angle )
163 {
164  return qwtPolar2Pos( pole, radius, angle / 180.0 * M_PI );
165 }
166 
167 inline QPointF qwtFastPolar2Pos( const QPointF& pole,
168  double radius, double angle )
169 {
170  const double x = pole.x() + radius * qFastCos( angle );
171  const double y = pole.y() - radius * qFastSin( angle );
172 
173  return QPointF( x, y);
174 }
175 
176 inline QPointF qwtFastDegree2Pos( const QPointF& pole,
177  double radius, double angle )
178 {
179  return qwtFastPolar2Pos( pole, radius, angle / 180.0 * M_PI );
180 }
181 
182 inline QwtPointPolar qwtFastPos2Polar( const QPointF& pos )
183 {
184  return QwtPointPolar( qwtFastAtan2( pos.y(), pos.x() ),
185  qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) );
186 }
187 
188 #endif
qwtSqr
double qwtSqr(double x)
Return the square of a number.
Definition: qwt_math.h:195
qwtFastPos2Polar
QwtPointPolar qwtFastPos2Polar(const QPointF &pos)
Definition: qwt_point_polar.h:182
QwtPointPolar::isNull
bool isNull() const
Returns true if radius() >= 0.0.
Definition: qwt_point_polar.h:96
QwtPointPolar::m_radius
double m_radius
Definition: qwt_point_polar.h:57
qwtFastAtan2
double qwtFastAtan2(double y, double x)
Approximation of arc tangent ( error below 0,005 radians )
Definition: qwt_math.h:213
Q_DECLARE_TYPEINFO
Q_DECLARE_TYPEINFO(QwtPointPolar, Q_MOVABLE_TYPE)
qwt_global.h
qwtPolar2Pos
QPoint qwtPolar2Pos(const QPoint &pole, double radius, double angle)
Definition: qwt_point_polar.h:137
mqtt_test_proto.x
x
Definition: mqtt_test_proto.py:34
qwt_math.h
QwtPointPolar::setRadius
void setRadius(double)
Sets the radius to radius.
Definition: qwt_point_polar.h:126
QwtPointPolar
A point in polar coordinates.
Definition: qwt_point_polar.h:28
mqtt_test_proto.y
y
Definition: mqtt_test_proto.py:35
operator<<
QWT_EXPORT QDebug operator<<(QDebug, const QwtPointPolar &)
Definition: qwt_point_polar.cpp:136
M_PI
#define M_PI
Definition: qwt_math.h:56
QwtPointPolar::azimuth
double azimuth() const
Returns the azimuth.
Definition: qwt_point_polar.h:108
QwtPointPolar::setAzimuth
void setAzimuth(double)
Sets the azimuth to azimuth.
Definition: qwt_point_polar.h:132
qwtFastDegree2Pos
QPointF qwtFastDegree2Pos(const QPointF &pole, double radius, double angle)
Definition: qwt_point_polar.h:176
operator==
bool operator==(QwtEventPattern::MousePattern b1, QwtEventPattern::MousePattern b2)
Compare operator.
Definition: qwt_event_pattern.h:228
sol::operator!=
constexpr bool operator!=(const optional< T > &lhs, const optional< U > &rhs)
\group relop
Definition: sol.hpp:6020
QwtPointPolar::rRadius
double & rRadius()
Returns the radius.
Definition: qwt_point_polar.h:114
QwtPointPolar::m_azimuth
double m_azimuth
Definition: qwt_point_polar.h:56
QwtPointPolar::rAzimuth
double & rAzimuth()
Returns the azimuth.
Definition: qwt_point_polar.h:120
QwtPointPolar::isValid
bool isValid() const
Returns true if radius() >= 0.0.
Definition: qwt_point_polar.h:90
QWT_EXPORT
#define QWT_EXPORT
Definition: qwt_global.h:38
QwtPointPolar::radius
double radius() const
Returns the radius.
Definition: qwt_point_polar.h:102
qwtDegree2Pos
QPoint qwtDegree2Pos(const QPoint &pole, double radius, double angle)
Definition: qwt_point_polar.h:146
qwtFastPolar2Pos
QPointF qwtFastPolar2Pos(const QPointF &pole, double radius, double angle)
Definition: qwt_point_polar.h:167
QwtPointPolar::QwtPointPolar
QwtPointPolar()
Definition: qwt_point_polar.h:71
QwtAxis::isValid
bool isValid(int axisPos)
Definition: qwt_axis.h:45


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46