PCL
ZenithalProjections.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/ZenithalProjections.h - Released 2024-06-18T15:48:54Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2024 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_ZenithalProjections_h
53 #define __PCL_ZenithalProjections_h
54 
56 
57 #include <pcl/Defs.h>
58 
59 #include <pcl/ProjectionBase.h>
60 
61 /*
62  * Based on original work contributed by AndrĂ©s del Pozo.
63  */
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
76 class PCL_CLASS ZenithalProjectionBase : public ProjectionBase
77 {
78 protected:
79 
84  {
85  m_theta0 = 90;
86  }
87 
92 
96  virtual ProjectionBase* Clone() const override = 0;
97 
101  virtual IsoString ProjCode() const override = 0;
102 
106  virtual IsoString Identifier() const override = 0;
107 
111  virtual IsoString Name() const override = 0;
112 
113 protected:
114 
118  bool Project( DPoint& pW, const DPoint& pN ) const noexcept override
119  {
120  double rTheta = GetRTheta( pN );
121  double sinTheta, cosTheta;
122  SinCos( Rad( pN.x ), sinTheta, cosTheta );
123  pW.x = rTheta * sinTheta;
124  pW.y = -rTheta * cosTheta;
125  return true;
126  }
127 
131  bool Unproject( DPoint& pN, const DPoint& pW ) const noexcept override
132  {
133  pN.x = Deg( ArcTan( pW.x, -pW.y ) );
134  pN.y = GetTheta( Sqrt( pW.x*pW.x + pW.y*pW.y ) );
135  return true;
136  }
137 
138  virtual double GetRTheta( const DPoint& np ) const = 0;
139  virtual double GetTheta( double rTheta ) const = 0;
140 };
141 
142 // ----------------------------------------------------------------------------
143 
151 {
152 public:
153 
158 
163 
167  ProjectionBase* Clone() const override
168  {
169  return new ZenithalEqualAreaProjection( *this );
170  }
171 
175  IsoString ProjCode() const override
176  {
177  return "ZEA";
178  }
179 
183  IsoString Identifier() const override
184  {
185  return "ZenithalEqualArea";
186  };
187 
191  IsoString Name() const override
192  {
193  return "Zenithal Equal Area";
194  }
195 
199  bool CheckBrokenLine( const DPoint& cp1, const DPoint& cp2 ) const noexcept override
200  {
201  DPoint np1 = m_sph.CelestialToNative( cp1 );
202  DPoint np2 = m_sph.CelestialToNative( cp2 );
203  return Min( Mod( Abs( np1.x - np2.x - 360 ), 360.0 ),
204  Mod( Abs( np1.x - np2.x + 360 ), 360.0 ) ) < 180*Sin( Rad( 45 + (np1.y + np2.y)/2/2 ) );
205  }
206 
207 private:
208 
209  double GetRTheta( const DPoint& np ) const override
210  {
211  return 2 * Deg( Sin( Rad( (90 - np.y)/2 ) ) );
212  }
213 
214  double GetTheta( double rTheta ) const override
215  {
216  return 90 - 2*Deg( ArcSin( Rad( rTheta )/2 ) );
217  }
218 };
219 
220 // ----------------------------------------------------------------------------
221 
229 {
230 public:
231 
236 
241 
245  ProjectionBase* Clone() const override
246  {
247  return new StereographicProjection( *this );
248  }
249 
253  IsoString ProjCode() const override
254  {
255  return "STG";
256  }
257 
261  IsoString Identifier() const override
262  {
263  return "Stereographic";
264  };
265 
269  IsoString Name() const override
270  {
271  return "Stereographic";
272  }
273 
277  bool CheckBrokenLine(const DPoint& cp1, const DPoint& cp2) const noexcept override
278  {
279  return true;
280  }
281 
282 private:
283 
284  double GetRTheta( const DPoint& np ) const override
285  {
286  return 2 * Deg( Tan( Rad( (90 - np.y)/2 ) ) );
287  }
288 
289  double GetTheta( double rTheta ) const override
290  {
291  return 90 - 2*Deg( ArcTan( Rad( rTheta )/2 ) );
292  }
293 };
294 
295 // ----------------------------------------------------------------------------
296 
297 } // pcl
298 
299 #endif // __PCL_ZenithalProjections_h
300 
301 // ----------------------------------------------------------------------------
302 // EOF pcl/ZenithalProjections.h - Released 2024-06-18T15:48:54Z
64-bit floating-point point in the R^2 space.
A generic point in the two-dimensional space.
Definition: Point.h:100
component x
Abscissa (horizontal, or X-axis coordinate).
Definition: Point.h:111
component y
Ordinate (vertical, or Y-axis coordinate).
Definition: Point.h:112
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5425
Base class of all projection systems.
Stereographic projection system.
IsoString Name() const override
IsoString Identifier() const override
IsoString ProjCode() const override
StereographicProjection(const StereographicProjection &)=default
ProjectionBase * Clone() const override
Zenithal equal-area projection system.
ProjectionBase * Clone() const override
IsoString ProjCode() const override
IsoString Name() const override
ZenithalEqualAreaProjection(const ZenithalEqualAreaProjection &)=default
IsoString Identifier() const override
Base class of zenithal projection systems.
virtual IsoString Name() const override=0
bool Project(DPoint &pW, const DPoint &pN) const noexcept override
virtual IsoString Identifier() const override=0
ZenithalProjectionBase(const ZenithalProjectionBase &)=default
bool Unproject(DPoint &pN, const DPoint &pW) const noexcept override
virtual IsoString ProjCode() const override=0
virtual ProjectionBase * Clone() const override=0
Complex< T > Sqrt(const Complex< T > &c) noexcept
Definition: Complex.h:674
T Abs(const Complex< T > &c) noexcept
Definition: Complex.h:429
Complex< T > Sin(const Complex< T > &c) noexcept
Definition: Complex.h:795
Complex< T > Tan(const Complex< T > &c) noexcept
Definition: Complex.h:817
void SinCos(T x, T &sx, T &cx) noexcept
Definition: Math.h:1030
constexpr T ArcTan(T x) noexcept
Definition: Math.h:526
constexpr T ArcSin(T x) noexcept
Definition: Math.h:514
constexpr T Rad(T x) noexcept
Definition: Math.h:1894
constexpr T Mod(T x, T y) noexcept
Definition: Math.h:887
constexpr T Deg(T x) noexcept
Definition: Math.h:606
constexpr const T & Min(const T &a, const T &b) noexcept
Definition: Utility.h:90
PCL root namespace.
Definition: AbstractImage.h:77