Stellarium 0.15.2
StelProjectorClasses.hpp
1 /*
2  * Stellarium
3  * Copyright (C) 2008 Stellarium Developers
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA.
18  */
19 
20 #ifndef _STELPROJECTIONS_HPP_
21 #define _STELPROJECTIONS_HPP_
22 
23 #include "StelProjector.hpp"
24 
26 {
27 public:
29  virtual QString getNameI18() const;
30  virtual QString getDescriptionI18() const;
31  virtual float getMaxFov() const {return 120.f;}
32  bool forward(Vec3f &v) const;
33  bool backward(Vec3d &v) const;
34  float fovToViewScalingFactor(float fov) const;
35  float viewScalingFactorToFov(float vsf) const;
36  float deltaZoom(float fov) const;
37 protected:
38  virtual bool hasDiscontinuity() const {return false;}
39  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {return false;}
40  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {return false;}
41 };
42 
44 {
45 public:
47  virtual QString getNameI18() const;
48  virtual QString getDescriptionI18() const;
49  virtual float getMaxFov() const {return 360.f;}
50  bool forward(Vec3f &v) const;
51  bool backward(Vec3d &v) const;
52  float fovToViewScalingFactor(float fov) const;
53  float viewScalingFactorToFov(float vsf) const;
54  float deltaZoom(float fov) const;
55 protected:
56  virtual bool hasDiscontinuity() const {return false;}
57  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {return false;}
58  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {return false;}
59 };
60 
62 {
63 public:
65  virtual QString getNameI18() const;
66  virtual QString getDescriptionI18() const;
67  virtual float getMaxFov() const {return 235.f;}
68  virtual void project(int n, const Vec3d* in, Vec3f* out)
69  {
70  Vec3d v;
71  for (int i = 0; i < n; ++i, ++out)
72  {
73  v = in[i];
74  modelViewTransform->forward(v);
75  out->set(v[0], v[1], v[2]);
77  out->set(viewportCenter[0] + flipHorz * pixelPerRad * (*out)[0],
78  viewportCenter[1] + flipVert * pixelPerRad * (*out)[1],
79  ((*out)[2] - zNear) * oneOverZNearMinusZFar);
80  }
81  }
82 
83  bool forward(Vec3f &v) const;
84  bool backward(Vec3d &v) const;
85  float fovToViewScalingFactor(float fov) const;
86  float viewScalingFactorToFov(float vsf) const;
87  float deltaZoom(float fov) const;
88 protected:
89  virtual bool hasDiscontinuity() const {return false;}
90  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {return false;}
91  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {return false;}
92 };
93 
95 {
96 public:
98  virtual QString getNameI18() const;
99  virtual QString getDescriptionI18() const;
100  virtual float getMaxFov() const {return 180.00001f;}
101  bool forward(Vec3f &v) const;
102  bool backward(Vec3d &v) const;
103  float fovToViewScalingFactor(float fov) const;
104  float viewScalingFactorToFov(float vsf) const;
105  float deltaZoom(float fov) const;
106 protected:
107  virtual bool hasDiscontinuity() const {return false;}
108  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {return false;}
109  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {return false;}
110 };
111 
113 {
114 public:
116  virtual QString getNameI18() const;
117  virtual QString getDescriptionI18() const;
118  virtual float getMaxFov() const {return 360.f;}
119  virtual void project(int n, const Vec3d* in, Vec3f* out)
120  {
121  Vec3d v;
122  for (int i = 0; i < n; ++i)
123  {
124  v = in[i];
125  modelViewTransform->forward(v);
126  out[i].set(v[0], v[1], v[2]);
128  out[i][0] = viewportCenter[0] + flipHorz * pixelPerRad * out[i][0];
129  out[i][1] = viewportCenter[1] + flipVert * pixelPerRad * out[i][1];
130  out[i][2] = (out[i][2] - zNear) * oneOverZNearMinusZFar;
131  }
132  }
133  bool forward(Vec3f &v) const;
134  bool backward(Vec3d &v) const;
135  float fovToViewScalingFactor(float fov) const;
136  float viewScalingFactorToFov(float vsf) const;
137  float deltaZoom(float fov) const;
138 protected:
139  virtual bool hasDiscontinuity() const {return true;}
140  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const {return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);}
141  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& capN, double capD) const
142  {
143  static const SphericalCap cap1(1,0,0);
144  static const SphericalCap cap2(-1,0,0);
145  static const SphericalCap cap3(0,0,-1);
146  SphericalCap cap(capN, capD);
147  return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap3);
148  }
149 };
150 
152 {
153 public:
155  virtual QString getNameI18() const;
156  virtual QString getDescriptionI18() const;
157  virtual float getMaxFov() const {return 175.f * 4.f/3.f;} // assume aspect ration of 4/3 for getting a full 360 degree horizon
158  bool forward(Vec3f &win) const;
159  bool backward(Vec3d &v) const;
160  float fovToViewScalingFactor(float fov) const;
161  float viewScalingFactorToFov(float vsf) const;
162  float deltaZoom(float fov) const;
163 protected:
164  virtual bool hasDiscontinuity() const {return true;}
165  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const
166  {
167  return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);
168  }
169  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& capN, double capD) const
170  {
171  static const SphericalCap cap1(1,0,0);
172  static const SphericalCap cap2(-1,0,0);
173  static const SphericalCap cap3(0,0,-1);
174  SphericalCap cap(capN, capD);
175  return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap2);
176  }
177 };
178 
180 {
181 public:
183  virtual QString getNameI18() const;
184  virtual QString getDescriptionI18() const;
185  virtual float getMaxFov() const {return 175.f * 4.f/3.f;} // assume aspect ration of 4/3 for getting a full 360 degree horizon
186  bool forward(Vec3f &win) const;
187  bool backward(Vec3d &v) const;
188  float fovToViewScalingFactor(float fov) const;
189  float viewScalingFactorToFov(float vsf) const;
190  float deltaZoom(float fov) const;
191 protected:
192  virtual bool hasDiscontinuity() const {return true;}
193  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& p1, const Vec3d& p2) const
194  {
195  return p1[0]*p2[0]<0 && !(p1[2]<0 && p2[2]<0);
196  }
197  virtual bool intersectViewportDiscontinuityInternal(const Vec3d& capN, double capD) const
198  {
199  static const SphericalCap cap1(1,0,0);
200  static const SphericalCap cap2(-1,0,0);
201  static const SphericalCap cap3(0,0,-1);
202  SphericalCap cap(capN, capD);
203  return cap.intersects(cap1) && cap.intersects(cap2) && cap.intersects(cap2);
204  }
205 };
206 
208 {
209 public:
211  virtual QString getNameI18() const;
212  virtual QString getDescriptionI18() const;
213  virtual float getMaxFov() const {return 179.9999f;}
214  bool forward(Vec3f &win) const;
215  bool backward(Vec3d &v) const;
216  float fovToViewScalingFactor(float fov) const;
217  float viewScalingFactorToFov(float vsf) const;
218  float deltaZoom(float fov) const;
219 protected:
220  virtual bool hasDiscontinuity() const {return false;}
221  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {return false;}
222  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {return false;}
223 };
224 
226 {
227 public:
229  virtual QString getNameI18() const;
230  virtual QString getDescriptionI18() const;
231  bool forward(Vec3f &win) const;
232  bool backward(Vec3d &v) const;
233 };
234 
236 {
237 public:
239  virtual QString getNameI18() const;
240  virtual QString getDescriptionI18() const;
241  virtual float getMaxFov() const {return 175.f * 4.f/3.f;} // or 180?
242  bool forward(Vec3f &win) const;
243  bool backward(Vec3d &v) const;
244 };
245 
247 {
248 public:
250  virtual QString getNameI18() const;
251  virtual QString getDescriptionI18() const;
252  virtual float getMaxFov() const {return 360.f;}
253  bool forward(Vec3f &win) const;
254  bool backward(Vec3d &v) const;
255  float fovToViewScalingFactor(float fov) const;
256  float viewScalingFactorToFov(float vsf) const;
257  float deltaZoom(float fov) const;
258 protected:
259  virtual bool hasDiscontinuity() const {return false;}
260  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, const Vec3d&) const {Q_ASSERT(0); return false;}
261  virtual bool intersectViewportDiscontinuityInternal(const Vec3d&, double) const {Q_ASSERT(0); return false;}
262  virtual void computeBoundingCap() {;}
263 };
264 
265 #endif // _STELPROJECTIONS_HPP_
266 
bool project(const Vec3d &v, Vec3d &win) const
Project the vector v from the current frame into the viewport.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
float deltaZoom(float fov) const
Return the small zoom increment to use at the given FOV for nice movements.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
float viewScalingFactorToFov(float vsf) const
Convert a ViewScalingFactor value (used internally) in Field Of View radius in radians.
A SphericalCap is defined by a direction and an aperture.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
bool backward(Vec3d &v) const
Apply the transformation in the backward projection in place.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
StelProjector(ModelViewTranformP amodelViewTransform)
Private constructor. Only StelCore can create instances of StelProjector.
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
virtual QString getDescriptionI18() const
Get a human-readable short description for this projection type.
Provide the main interface to all operations of projecting coordinates from sky to screen...
float fovToViewScalingFactor(float fov) const
Convert a Field Of View radius value in radians in ViewScalingFactor (used internally) ...
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
bool forward(Vec3f &v) const
Apply the transformation in the forward direction in place.
QSharedPointer< ModelViewTranform > ModelViewTranformP
Shared pointer on a ModelViewTranform instance (implement reference counting)
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool hasDiscontinuity() const
Return whether the projection presents discontinuities. Used for optimization.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual void computeBoundingCap()
Initialize the bounding cap.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, double) const
Determine whether a cap intersects with a projection discontinuity.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &, const Vec3d &) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &capN, double capD) const
Determine whether a cap intersects with a projection discontinuity.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual QString getNameI18() const
Get a human-readable name for this projection type.
virtual float getMaxFov() const
Get the maximum FOV apperture in degree.
virtual bool intersectViewportDiscontinuityInternal(const Vec3d &p1, const Vec3d &p2) const
Determine whether a great circle connection p1 and p2 intersects with a projection discontinuity...