isce3  0.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Point.h
1 // Copyright (c) 2017-, California Institute of Technology ("Caltech"). U.S.
2 // Government sponsorship acknowledged.
3 // All rights reserved.
4 //
5 // Author(s):
6 //
7 // ------------------------------------------------------------------------------
8 // Point class definitions
9 // ------------------------------------------------------------------------------
10 
11 #pragma once
12 
13 #include <iostream>
14 #include <iomanip>
15 #include <string.h>
16 #include <math.h>
17 
18 class USPoint {
19 
20  friend std::ostream& operator<< (std::ostream&, USPoint);
21  public:
22 
23  unsigned short x;
24  unsigned short y;
25 
26  public :
27 
28  USPoint () { x = 0; y = 0;}
29  USPoint (unsigned short a, unsigned short b) { x = a; y = b; }
30  ~USPoint () {}
31 
32  USPoint(const USPoint& source_point) {
33  x = source_point.x;
34  y = source_point.y;
35  }
36  USPoint& operator=(const USPoint& source_point) {
37  x = source_point.x;
38  y = source_point.y;
39  return *this;
40  }
41 
42  // operators :
43 
44  USPoint operator() (unsigned short a, unsigned short b);
45  /*
46  bool operator == (const USPoint &b) const {
47  if(x == b.x && y == b.y) return true;
48  else return false;
49  }
50  */
51  bool operator < (const USPoint &b) const {
52  if(x*32768 + y < b.x*32768 + b.y) return true;
53  else return false;
54  }
55  /*
56  bool operator != (const USPoint &b) const {
57  if(x == b.x && y == b.y) return false;
58  else return true;
59  }
60  bool operator <= (const USPoint &b) const {
61  if(y <= b.y) return true;
62  else return false;
63  }
64  bool operator > (const USPoint &b) const {
65  if(y > b.y) return true;
66  else return false;
67  }
68  bool operator >= (const USPoint &b) const {
69  if(y >= b.y) return true;
70  else return false;
71  }
72  */
73 
74  void set (int a, int b) { x = a; y = b; }
75  int get_X() { return x; }
76  int get_Y() { return y; }
77 };
78 
79 
80 class USF3Point {
81 
82  friend std::ostream& operator<< (std::ostream&, USF3Point);
83 
84  public:
85 
86  unsigned short line;
87  unsigned short pixel;
88  float x;
89 
90  public :
91 
92  USF3Point () { line = 0; pixel = 0; x = 0;}
93  USF3Point (unsigned short s_, unsigned short c_, float x_) { line = s_; pixel = c_; x = x_;}
94  ~USF3Point () {}
95  USF3Point operator() (unsigned short line_, unsigned short pixel_, float x_);
96 
97  USF3Point(const USF3Point& source_point) {
98  line = source_point.line;
99  pixel = source_point.pixel;
100  x = source_point.x;
101  }
102  USF3Point& operator=(const USF3Point& source_point) {
103  line = source_point.line;
104  pixel = source_point.pixel;
105  x = source_point.x;
106  return *this;
107  }
108 
109  bool operator < (const USF3Point &b) const {
110  if(line*32768 + pixel < b.line*32768 + b.pixel) return true;
111  else return false;
112  }
113 
114  void set(int s_, int c_, float x_) { line = s_; pixel = c_; x = x_;}
115 };
116 
117 
118 class USF4Point {
119 
120  friend std::ostream& operator<< (std::ostream&, USF4Point);
121 
122  public:
123 
124  unsigned short s;
125  unsigned short c;
126  float x;
127  float y;
128 
129  public :
130 
131  USF4Point () { s = 0; c = 0; x = 0; y = 0;}
132  USF4Point (unsigned short s_, unsigned short c_, float x_, float y_) { s = s_; c = c_; x = x_; y = y_; }
133  ~USF4Point () {}
134  USF4Point operator() (unsigned short s_, unsigned short c_, float x_, float y_);
135 
136  USF4Point(const USF4Point& source_point) {
137  s = source_point.s;
138  c = source_point.c;
139  x = source_point.x;
140  y = source_point.y;
141  }
142  USF4Point& operator=(const USF4Point& source_point) {
143  s = source_point.s;
144  c = source_point.c;
145  x = source_point.x;
146  y = source_point.y;
147  return *this;
148  }
149 
150  bool operator < (const USF4Point &b) const {
151  if(s*32768 + c < b.s*32768 + b.c) return true;
152  else return false;
153  }
154 
155  void set(int s_, int c_, float x_, float y_) { s = s_; c = c_; x = x_; y = y_; }
156 };
157 
158 
159 class USPointKey {
160 
161  friend std::ostream& operator<< (std::ostream&, USPointKey);
162  friend std::istream& operator>> (std::istream&, USPointKey &);
163 
164  public:
165 
166  unsigned short x;
167  unsigned short y;
168  int key;
169 
170  public :
171 
172  USPointKey () { x = 0; y = 0; key = 0; }
173  USPointKey (unsigned short a, unsigned short b, int key_) { x = a; y = b; key = key_;}
174  ~USPointKey () {}
175 
176  USPointKey(const USPointKey& source_point) {
177  x = source_point.x;
178  y = source_point.y;
179  key = source_point.key;
180  }
181  USPointKey& operator=(const USPointKey& source_point) {
182  x = source_point.x;
183  y = source_point.y;
184  key = source_point.key;
185  return *this;
186  }
187  // operators :
188 
189  USPointKey operator() (unsigned short a, unsigned short b, int key_);
190  int operator== (const USPointKey &a);
191  bool operator < (const USPointKey &a) const {
192  return key > a.key;
193  }
194 
195 };
196 
197 
199 {
200  bool reverse;
201 
202 public:
203  USPointKeyComp(const bool& revparam=false) { reverse = revparam; }
204  bool operator() (const USPointKey & first, const USPointKey & second) const
205  {
206  if (reverse) {
207  return (first.key > second.key);
208  }
209  else return ( first.key < second.key );
210  }
211 };
212 
213 
214 class Point {
215 
216  friend std::ostream& operator<< (std::ostream&, Point);
217  friend std::istream& operator>> (std::istream&, Point &);
218 
219  public:
220 
221  int x;
222  int y;
223 
224  public :
225 
226  Point () { x = 0; y = 0; }
227  Point (int a, int b) { x = a; y = b; }
228  ~Point () {}
229 
230  void set (int a, int b) { x = a; y = b; }
231  void get (int& a, int& b) { a = x; b = y; }
232 
233  int get_X() { return x; }
234  int get_Y() { return y; }
235 
236  void set_X(int a) { x = a; }
237  void set_Y(int b) { y = b; }
238 
239  double magnitude () { return sqrt(x*x + y*y); }
240 
241  // operators :
242 
243  bool operator < (const Point &b) const {
244  return (x + y*1073741824 < b.x + b.y*1073741824);
245  }
246 
247  Point operator() (int a, int b);
248  Point operator+ (const Point &a);
249  Point operator- (const Point &a);
250  Point operator* (int a);
251  Point &operator+= (const Point &a);
252  Point &operator-= (const Point &a);
253  Point operator~ ();
254  int operator* (const Point &a);
255  int operator== (const Point &a);
256 
257  friend Point operator* (const int &d, const Point &a);
258 
259 };
260 
261 class PointKey {
262 
263  friend std::ostream& operator<< (std::ostream &stream, PointKey a) {
264  stream << "(" << a.point.x << ", " << a.point.y << ", " << a.key << ")" ;
265  return stream;
266  }
267 
268  public:
269  Point point;
270  int key;
271 
272  public :
273 
274  PointKey () { point = Point(0,0); key = 0; }
275  PointKey (int x_, int y_, int key_) { point = Point(x_, y_); key = key_;}
276  PointKey (Point point_, int key_) { point = point_; key = key_;}
277  ~PointKey () {}
278 
279  PointKey(const PointKey& source_point) {
280  point = source_point.point;
281  key = source_point.key;
282  }
283  PointKey& operator=(const PointKey& source_point) {
284  point = source_point.point;
285  key = source_point.key;
286  return *this;
287  }
288  // operators :
289 
290  int operator == (const PointKey &a) {
291  return (point == a.point) && (key = a.key);
292  }
293 
294  bool operator < (const PointKey &a) const {
295  return key > a.key;
296  }
297 };
298 
299 /*
300 struct PointKeyComp
301 {
302  bool operator()(const PointKey &k1, const PointKey &k2) const {
303  return k1.key < k2.key;
304  }
305 };
306 */
307 
308 /*
309 class PointComp
310 {
311  bool reverse;
312 
313 public:
314  PointComp(const bool& revparam=false) { reverse = revparam; }
315  bool operator() (const Point& first, const Point& second) const
316  {
317  if (reverse) {
318  return (first.y > second.y);
319  }
320  else return ( first.y < second.y );
321  }
322 };
323 */
324 //------------------------------------------------------------------------------
325 //------------------------------------------------------------------------------
326 
327 class F2point {
328 
329  friend std::ostream& operator<< (std::ostream&, F2point);
330  friend std::istream& operator>> (std::istream&, F2point &);
331 
332  public:
333 
334  float x;
335  float y;
336 
337  public :
338 
339  F2point () { x = 0; y = 0; }
340  F2point (float a, float b) { x = a; y = b; }
341  F2point (float *a) { x = a[0]; y = a[1]; }
342  ~F2point () {}
343 
344  F2point(const F2point& source_point) {
345  x = source_point.x;
346  y = source_point.y;
347  }
348  F2point& operator=(const F2point& source_point) {
349  x = source_point.x;
350  y = source_point.y;
351  return *this;
352  }
353 };
354 
355 class F3point {
356 
357  friend std::ostream& operator<< (std::ostream&, F3point);
358  friend std::istream& operator>> (std::istream&, F3point &);
359 
360  public:
361 
362  float x;
363  float y;
364  float z;
365 
366  public :
367 
368  F3point () { x = 0; y = 0; z = 0; }
369  F3point (float a, float b, float c) { x = a; y = b; z = c; }
370  F3point (float *a) { x = a[0]; y = a[1]; z = a[2];}
371  ~F3point () {}
372 
373  F3point(const F3point& source_point) {
374  x = source_point.x;
375  y = source_point.y;
376  z = source_point.z;
377  }
378  F3point& operator=(const F3point& source_point) {
379  x = source_point.x;
380  y = source_point.y;
381  z = source_point.z;
382  return *this;
383  }
384 };
385 
386 
387 class D2point {
388 
389  friend std::ostream& operator<< (std::ostream&, D2point);
390  friend std::istream& operator>> (std::istream&, D2point &);
391 
392  public:
393 
394  double x;
395  double y;
396 
397  public :
398 
399  D2point () { x = 0; y = 0; }
400  D2point (double a, double b) { x = a; y = b; }
401  D2point (double *a) { x = a[0]; y = a[1]; }
402  ~D2point () {}
403 
404  void set (double a, double b) { x = a; y = b; }
405  void get (double& a, double& b) { a = x; b = y; }
406 
407  double get_X() { return x; }
408  double get_Y() { return y; }
409 
410  void set_X(double a) { x = a; }
411  void set_Y(double a) { y = a; }
412 
413  double magnitude () { return sqrt(x*x + y*y); }
414 
415  // operators :
416 
417  D2point operator() (double a, double b);
418  D2point operator+ (const D2point &a);
419  // D2point operator+ (D2point const &a);
420  D2point operator- (const D2point &a) const;
421  D2point operator* (const double &d);
422  D2point operator/ (const double &d);
423  D2point &operator+= (const D2point &a);
424  D2point &operator-= (const D2point &a);
425  D2point operator~ ();
426  double operator* (const D2point &a);
427  int operator== (const D2point &a) const;
428 
429  friend D2point operator*(const double &d, const D2point &a);
430 
431  D2point(const D2point& source_point) {
432  x = source_point.x;
433  y = source_point.y;
434  }
435  D2point& operator=(const D2point& source_point) {
436  x = source_point.x;
437  y = source_point.y;
438  return *this;
439  }
440 
441 };
442 
443 
444 //------------------------------------------------------------------------------
445 //------------------------------------------------------------------------------
446 
447 //class D3point : public D2point {
448 class D3point {
449 
450  friend std::ostream& operator<< (std::ostream&, D3point);
451  friend std::istream& operator>> (std::istream&, D3point &);
452 
453  public: // members
454 
455  double x;
456  double y;
457  double z;
458 
459  public :
460 
461  D3point () { x=0; y=0; z=0; }
462  D3point (double a, double b, double c) { x=a; y=b; z=c; }
463  D3point (double *a) { x=a[0]; y=a[1]; z=a[2]; }
464  ~D3point () {}
465 
466  void get (double& a, double& b, double& c) { a=x; b=y; c=z; }
467  double get_Z() { return z; }
468  void set_Z(double c) { z = c; }
469  void get (double& a, double& b) { a = x; b = y; }
470 
471  double get_x() { return x; }
472  double get_y() { return y; }
473 
474  D3point unity ();
475  double magnitude () const { return sqrt(x*x + y*y + z*z); }
476  double magnitude2 () const { return x*x + y*y + z*z; }
477  void set(double xpos,double ypos,double zpos) { x=xpos; y=ypos; z=zpos; }
478  void set(double xpos,double ypos) { x=xpos; y=ypos; }
479 
480 
481  // operators:
482 
483  D3point operator() (double a, double b, double c); // (x,y,z)
484 
485  D3point operator+ (const D3point &a);
486  D3point operator- (const D3point &a);
487  D3point operator* (const double &s); // vector * scalar
488  D3point operator/ (const double &s); // divide by a scalar
489  D3point operator+= (const D3point &a);
490  D3point operator-= (const D3point &a);
491  D3point operator*= (const double &s); // vector * scalar
492  D3point operator/= (const double &s); // divide by a scalar
493  D3point operator&& (const D3point &a); // cross product
494 
495  double operator* (const D3point &a); // scalar product
496  double operator< (const D3point &a); // angle between vectors
497 
498  int operator== (const D3point &a);
499  int operator!= (const D3point &a);
500 
501  friend D3point operator*(const double &s, const D3point &a);
502 
503  D3point(const D3point& source_point) {
504  x = source_point.x;
505  y = source_point.y;
506  z = source_point.z;
507  }
508  D3point& operator=(const D3point& source_point) {
509  x = source_point.x;
510  y = source_point.y;
511  z = source_point.z;
512  return *this;
513  }
514 };
515 
516 
517 //------------------------------------------------------------------------------
518 
519 class Geopoint {
520 
521  friend std::ostream& operator<< (std::ostream&, Geopoint);
522  friend std::istream& operator>> (std::istream&, Geopoint&);
523 
524  public:
525 
526  double lat, lon; // geodetic angles in radians
527  double alt; // altitude in meters
528 
529  public :
530 
531  Geopoint () { lat = 0; lon = 0; alt = 0; }
532 
533  Geopoint ( double Lat, double Lon, double Alt = 0.0 ) { lat = Lat; lon = Lon; alt = Alt; }
534 
535  ~Geopoint () {}
536 
537  Geopoint operator() ( double Lat, double Lon, double Alt ); // alt in meters
538 
539  Geopoint& operator= (const Geopoint&);
540 
541  void get (double& Lat, double& Lon) { Lat = lat; Lon = lon; }
542  void get (double& Lat, double& Lon, double& Alt) { Lat = lat; Lon = lon; Alt = alt; }
543  void get (double& Alt) {Alt = alt; }
544 
545  double Lat () {return lat;}
546  double Lon () {return lon;}
547  double Alt () {return alt;}
548 
549  void set(double Lat,double Lon,double Alt){
550  lat = Lat; lon = Lon; alt = Alt;
551  }
552  void set_alt(double Alt){alt = Alt;}
553 
554 
555 
556  Geopoint(const Geopoint& source_point) {
557  lat = source_point.lat;
558  lon = source_point.lon;
559  alt = source_point.alt;
560  }
561 
562 };
563 
564 double cross(Point p1, Point p2);
565 double cross(D2point p1, D2point p2);
Definition: Point.h:327
Definition: Point.h:448
Definition: Point.h:214
Definition: Point.h:80
Definition: Point.h:355
Definition: Point.h:198
Definition: Point.h:387
Definition: Point.h:519
Definition: Point.h:261
Definition: Point.h:159
Definition: Point.h:118
Definition: Point.h:18

Generated for ISCE3.0 by doxygen 1.8.5.