Kstars

SpatialVector.h
1#ifndef _SpatialVector_h
2#define _SpatialVector_h
3
4//# Filename: SpatialVector.h
5//#
6//# Standard 3-d vector class
7//#
8//# Author: Peter Z. Kunszt, based on A. Szalay's code
9//#
10//# Date: October 15, 1998
11//#
12//# SPDX-FileCopyrightText: 2000 Peter Z. Kunszt Alex S. Szalay, Aniruddha R. Thakar
13//# The Johns Hopkins University
14//#
15//# Modification History:
16//#
17//# Oct 18, 2001 : Dennis C. Dinge -- Replaced ValVec with std::vector
18//#
19
20#include <cmath>
21#include <SpatialGeneral.h>
22
23//########################################################################
24/**
25 @class SpatialVector
26 SpatialVector is a 3D vector usually living on the surface of
27 the sphere. The corresponding ra, dec can be obtained if the vector
28 has unit length. That can be ensured with the normalize() function.
29
30*/
31
32class LINKAGE SpatialVector
33{
34 public:
35 /// constructs (1,0,0), ra=0, dec=0.
37
38 /// Constructor from three coordinates, not necessarily normed to 1
39 SpatialVector(float64 x, float64 y, float64 z);
40
41 /// Constructor from ra/dec, this is always normed to 1
42 SpatialVector(float64 ra, float64 dec);
43
44 /// Set member function: set values - always normed to 1
45 void set(const float64 &x, const float64 &y, const float64 &z);
46
47 /// Set member function: set values - always normed to 1
48 void set(const float64 &ra, const float64 &dec);
49
50 /// Get x,y,z
51 void get(float64 &x, float64 &y, float64 &z) const;
52
53 /// Get ra,dec - normalizes x,y,z
54 void get(float64 &ra, float64 &dec);
55
56 /// return length of vector
57 float64 length() const;
58
59 /// return x (only as rvalue)
60 float64 x() const { return x_; }
61
62 /// return y
63 float64 y() const { return y_; }
64
65 /// return z
66 float64 z() const { return z_; }
67
68 /// return ra - this norms the vector to 1 if not already done so
69 float64 ra();
70
71 /// return dec - this norms the vector to 1 if not already done so
72 float64 dec();
73
74 /// Normalize vector length to 1
75 void normalize();
76
77 /// Comparison
78 int operator==(const SpatialVector &) const;
79
80 /// dot product
81 float64 operator*(const SpatialVector &)const;
82
83 /// cross product
84 SpatialVector operator^(const SpatialVector &) const;
85
86 /// addition
87 SpatialVector operator+(const SpatialVector &) const;
88
89 /// subtraction
90 SpatialVector operator-(const SpatialVector &) const;
91
92 /** @name Scalar products with int and float */
93 //@{
94 /** @name operator *= */
95 SpatialVector &operator*=(float64);
96 SpatialVector &operator*=(int);
97 friend SpatialVector operator*(float64, const SpatialVector &);
98 friend SpatialVector operator*(int, const SpatialVector &);
99 friend SpatialVector operator*(const SpatialVector &, float64);
100 friend SpatialVector operator*(const SpatialVector &, int);
101 //@}
102
103 private:
104 float64 x_;
105 float64 y_;
106 float64 z_;
107 float64 ra_;
108 float64 dec_;
109 bool okRaDec_;
110
111 void updateXYZ();
112 void updateRaDec();
113
114 friend class SpatialIndex;
115};
116
117// Friend operators
118SpatialVector operator*(float64, const SpatialVector &);
119SpatialVector operator*(int, const SpatialVector &);
120SpatialVector operator*(const SpatialVector &, float64);
121SpatialVector operator*(const SpatialVector &, int);
122
123#endif
SpatialIndex is a quad tree of spherical triangles.
SpatialVector is a 3D vector usually living on the surface of the sphere.
float64 y() const
return y
float64 z() const
return z
float64 x() const
return x (only as rvalue)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.