libatomprobe
Library for Atom Probe Tomography (APT) computation
projection.h
Go to the documentation of this file.
1 /* projection.cpp : Stereographic and related projection computations
2  * Copyright (C) 2020 Daniel Haley
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef ATOMPROBE_PROJECTION_H
19 #define ATOMPROBE_PROJECTION_H
20 
22 
23 namespace AtomProbe
24 {
25 
26 //Class that allows for conversion of coordinate systems from
27 // a spherical to a planar surface, touching the sphere apex.
28 // non-unit solutions can be obtained by appropriate scaling transforms
29 // off-axis projections can be obtained by a pre-rotation
30 
31 // The coordinate system is a unit sphere, at centre=(0,0,0)
32 // the tip axis lies parallel to z
33 // the plane is located at z=1.
34 // The spherical coordinate system is ISO31-11 (aka ISO: 80000-2)
35 // See https://en.wikipedia.org/wiki/ISO_31-11#Coordinate_systems
36 // also https://upload.wikimedia.org/wikipedia/commons/b/ba/Comparison_azimuthal_projections.svg
38 {
39  public:
41 
43  virtual bool toAzimuthal(float fx,float fy, float &theta, float &phi) const = 0;
45  virtual bool toPlanar(float theta ,float phi, float &fx, float &fy) const = 0;
46 
48  virtual void scaleDown(float flightLength,float detX,float detY,
49  float &scaledX,float &scaledY) const =0;
50 
52  virtual void scaleUp(float flightLength,float scaledX, float scaledY,
53  float &realX, float &realY) const=0;
54 
55  virtual float thetaToEta(float theta) const = 0;
56 };
57 
58 //TODO: In theory we could make this a single projection class,
59 // and have the operator switch modes. What is best?
60 
61 //Pure gnomonic projection, where projection
62 // focus is at the sphere centre
64 {
65  public:
67  // Returns false if transform is not possible
68  virtual bool toAzimuthal(float fx,float fy, float &theta, float &phi) const ;
70  // note that there is a degeneracy in theta at fx=fy=0
71  virtual bool toPlanar(float theta ,float phi, float &fx, float &fy) const ;
72 
73 
75  virtual void scaleDown(float flightLength,float detX,float detY,
76  float &scaledX,float &scaledY) const;
77 
79  virtual void scaleUp(float flightLength,float scaledX,float scaledY,
80  float &realX, float &realY) const;
81 
82  float thetaToEta(float theta) const {return theta;}
83 
84 };
85 
86 //Pure stereographic projection, where projection focus is at rear of sphere
87 // (z=-1)
88 // In this transform, theta no longer follows ISO31-11 coordinate systems
89 // theta has range [0,PI/2). See docs/ folder for SVG diagram
91 {
92  public:
94  // Returns false if transform is not possible
95  virtual bool toAzimuthal(float fx,float fy, float &theta, float &phi) const ;
97  virtual bool toPlanar(float theta ,float phi, float &fx, float &fy) const ;
98 
100  virtual void scaleDown(float flightLength,float detX,float detY,
101  float &scaledX,float &scaledY) const;
102 
104  virtual void scaleUp(float flightLength,float scaledX, float scaledY,
105  float &realX, float &realY) const;
106 
108 
110  float thetaToEta(float theta) const;
111 
112 };
113 
114 //This is a spheric projection that allows for the focus to be moved
115 // a focus of 0 corresponds to gnomonic, a focus of 1 corresponds to stereographic,
116 // >1 is a "Far side general perspective" projection
118 {
119  private:
120  //Distance from sphere centre, away from plane (towards "south pole") that the focus is located at
121  float focusDist;
122 
124  // theta, given rotational symmetrical reduction to 2D problem
125  bool getProjectionPt(float theta,float &f) const;
126 
127 
128  public:
130  ModifiedFocusSphericProjection(float focus);
131 
133  void setFocus(float focus);
135  /* !theta is the azimuthal angle is from focal point, x axis and projection vector
136  eta is the spherical angle is from sphere centre to projection point with x axis.
137  Note that using eta will place projected points correctly on the sphere, but not on the projected plane
138  valid inputs are in range [0,2*PI] */
139  float etaToTheta(float eta) const;
140 
142 
144  float thetaToEta(float theta) const;
145 
147  /* Returns false if transform is not possible
148  */
149  virtual bool toAzimuthal(float fx,float fy, float &theta, float &phi) const ;
151  /* note that there is a degeneracy in theta at fx=fy=0
152  */
153  virtual bool toPlanar(float theta ,float phi, float &fx, float &fy) const ;
154 
156  virtual void scaleDown(float flightLength,float detX,float detY,
157  float &scaledX,float &scaledY) const;
158 
160  virtual void scaleUp(float flightLength,float scaledX, float scaledY,
161  float &realX, float &realY) const;
162 
163 
165 
167  float getMaxFOV() const;
168 
170  float getFOVRadius(float eta) const;
171 
172 
173 };
174 
175 #ifdef DEBUG
176 bool testProjection();
177 #endif
178 }
179 #endif
virtual float thetaToEta(float theta) const =0
virtual void scaleUp(float flightLength, float scaledX, float scaledY, float &realX, float &realY) const =0
Convert from scaled-down coordinates to actual size.
virtual bool toAzimuthal(float fx, float fy, float &theta, float &phi) const =0
Convert from plane coordinates to projection coords.
float thetaToEta(float theta) const
Definition: projection.h:82
virtual bool toPlanar(float theta, float phi, float &fx, float &fy) const =0
Convert from spherical planar coordinates to projection coords.
virtual void scaleDown(float flightLength, float detX, float detY, float &scaledX, float &scaledY) const =0
Convert from actual detector postion (eg. mm) and flight path to scaled-down transform.