Omnidome
Fulldome Mapping Software Toolkit
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PolarVec.h
Go to the documentation of this file.
1 /* Copyright (c) 2014-2015 "Omnidome" by cr8tr
2  * Dome Mapping Projection Software (http://omnido.me).
3  * Omnidome was created by Michael Winkelmann aka Wilston Oreo (@WilstonOreo)
4  *
5  * This file is part of Omnidome.
6  *
7  * Omnidome is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU Affero General Public License as
9  * published by the Free Software Foundation, either version 3 of the
10  * License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU Affero General Public License for more details.
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef OMNI_GEOMETRY_POLARVEC_H_
21 #define OMNI_GEOMETRY_POLARVEC_H_
22 
23 #include <QVector3D>
24 #include <QVector4D>
25 #include <omni/geometry/Angle.h>
27 
28 namespace omni {
29  namespace geometry {
30  /** @brief polar 3D vector defined by th two angles phi, theta and a radial
31  distance
32  **/
33  struct PolarVec
34  {
35  public:
36  /// default constructor
37  PolarVec();
38 
39  /// Construct from QVector3D
40  PolarVec(const QVector3D&);
41 
42  /// Construct from QVector4D
43  PolarVec(const QVector4D&);
44 
45  /// Construct from longitude angle, latitude angle and radius
46  PolarVec(Angle _longitude,
47  Angle _latitude,
48  qreal _radius);
49 
50  /// Assign from QVector3D
51  const PolarVec& operator=(const QVector3D&);
52 
53  /// QVector3D cast operator
54  operator QVector3D() const;
55 
56  /// QVector4D cast operator
57  operator QVector4D() const;
58 
59  /// Increase by other PolarVec
60  const PolarVec& operator+=(const PolarVec&);
61 
62  /// Return x value (by converting to QVector3D internally)
63  qreal x() const;
64 
65  /// Return y value (by converting to QVector3D internally)
66  qreal y() const;
67 
68  /// Return z value (by converting to QVector3D internally)
69  qreal z() const;
70 
71  /// Return converted QVector3D
72  QVector3D vec() const;
73 
74  /// Returns normalized QVector3D
75  QVector3D normalized() const;
76 
77  /// Return longitudinal angle
78  Angle longitude() const;
79 
80  /// Set longitudinal angle
81  void setLongitude(Angle);
82 
83  /// Return latitudinal angle
84  Angle latitude() const;
85 
86  /// Set latitudinal angle
87  void setLatitude(Angle);
88 
89  /// Return radius
90  qreal radius() const;
91 
92  /// Set radius
93  void setRadius(qreal);
94 
95  /// Write transformation to stream
96  void toStream(QDataStream&) const;
97 
98  /// Read transformation from stream
99  void fromStream(QDataStream&);
100 
101  /// Test for equality
102  friend bool operator==(PolarVec const&,
103  PolarVec const&);
104 
105  private:
107  qreal radius_;
108  };
109  }
110 
111  using geometry::PolarVec;
112 }
113 
115 
116 #endif /* OMNI_GEOMETRY_POLARVEC_H_ */
const PolarVec & operator+=(const PolarVec &)
Increase by other PolarVec.
Definition: PolarVec.cpp:76
Angle latitude() const
Return latitudinal angle.
Definition: PolarVec.cpp:128
friend bool operator==(PolarVec const &, PolarVec const &)
Test for equality.
Definition: PolarVec.cpp:158
const PolarVec & operator=(const QVector3D &)
Assign from QVector3D.
Definition: PolarVec.cpp:49
void toStream(QDataStream &) const
Write transformation to stream.
Definition: PolarVec.cpp:149
qreal radius_
Definition: PolarVec.h:107
Angle longitude_
Definition: PolarVec.h:106
qreal radius() const
Return radius.
Definition: PolarVec.cpp:138
void fromStream(QDataStream &)
Read transformation from stream.
Definition: PolarVec.cpp:154
qreal y() const
Return y value (by converting to QVector3D internally)
Definition: PolarVec.cpp:98
polar 3D vector defined by th two angles phi, theta and a radial distance
Definition: PolarVec.h:33
#define OMNI_DECL_STREAM_OPERATORS(CLASS)
Definition: Interface.h:53
Angle longitude() const
Return longitudinal angle.
Definition: PolarVec.cpp:118
Angle latitude_
Definition: PolarVec.h:106
QVector3D normalized() const
Returns normalized QVector3D.
Definition: PolarVec.cpp:113
qreal z() const
Return z value (by converting to QVector3D internally)
Definition: PolarVec.cpp:103
QVector3D vec() const
Return converted QVector3D.
Definition: PolarVec.cpp:108
void setRadius(qreal)
Set radius.
Definition: PolarVec.cpp:143
Struct for representing an angle (stored in degrees internally)
Definition: Angle.h:28
void setLatitude(Angle)
Set latitudinal angle.
Definition: PolarVec.cpp:133
qreal x() const
Return x value (by converting to QVector3D internally)
Definition: PolarVec.cpp:93
void setLongitude(Angle)
Set longitudinal angle.
Definition: PolarVec.cpp:123
PolarVec()
default constructor
Definition: PolarVec.cpp:27