File indexing completed on 2025-01-18 09:54:36
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef HEP_POINT3D_H
0015 #define HEP_POINT3D_H
0016
0017 #include <iosfwd>
0018 #include "CLHEP/Geometry/defs.h"
0019 #include "CLHEP/Vector/ThreeVector.h"
0020 #include "CLHEP/Geometry/BasicVector3D.h"
0021
0022 namespace HepGeom {
0023
0024 class Transform3D;
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 template<class T>
0035 class Point3D : public BasicVector3D<T> {};
0036
0037
0038
0039
0040
0041
0042
0043 template<>
0044 class Point3D<float> : public BasicVector3D<float> {
0045 public:
0046
0047
0048 Point3D() = default;
0049
0050
0051
0052 Point3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
0053
0054
0055
0056 explicit Point3D(const float * a)
0057 : BasicVector3D<float>(a[0],a[1],a[2]) {}
0058
0059
0060
0061 Point3D(const Point3D<float> &) = default;
0062
0063
0064
0065 Point3D(Point3D<float> &&) = default;
0066
0067
0068
0069 Point3D(const BasicVector3D<float> & v) : BasicVector3D<float>(v) {}
0070
0071
0072
0073 ~Point3D() = default;
0074
0075
0076
0077 Point3D<float> & operator=(const Point3D<float> &) = default;
0078
0079
0080
0081 Point3D<float> & operator=(const BasicVector3D<float> & v) {
0082 this->BasicVector3D<float>::operator=(v);
0083 return *this;
0084 }
0085
0086
0087
0088 Point3D<float> & operator=(Point3D<float> &&) = default;
0089
0090
0091
0092 float distance2() const { return mag2(); }
0093
0094
0095
0096 float distance2(const Point3D<float> & p) const {
0097 float dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
0098 return dx*dx + dy*dy + dz*dz;
0099 }
0100
0101
0102
0103 float distance() const { return std::sqrt(distance2()); }
0104
0105
0106
0107 float distance(const Point3D<float> & p) const {
0108 return std::sqrt(distance2(p));
0109 }
0110
0111
0112
0113 Point3D<float> & transform(const Transform3D & m);
0114 };
0115
0116
0117
0118
0119
0120 Point3D<float>
0121 operator*(const Transform3D & m, const Point3D<float> & p);
0122
0123
0124
0125
0126
0127
0128
0129 template<>
0130 class Point3D<double> : public BasicVector3D<double> {
0131 public:
0132
0133
0134 Point3D() = default;
0135
0136
0137
0138 Point3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
0139
0140
0141
0142 explicit Point3D(const float * a)
0143 : BasicVector3D<double>(a[0],a[1],a[2]) {}
0144
0145
0146
0147 explicit Point3D(const double * a)
0148 : BasicVector3D<double>(a[0],a[1],a[2]) {}
0149
0150
0151
0152 Point3D(const Point3D<double> &) = default;
0153
0154
0155
0156 Point3D(Point3D<double> &&) = default;
0157
0158
0159
0160 Point3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
0161
0162
0163
0164 Point3D(const BasicVector3D<double> & v) : BasicVector3D<double>(v) {}
0165
0166
0167
0168 ~Point3D() = default;
0169
0170
0171
0172
0173
0174
0175 Point3D(const CLHEP::Hep3Vector & v)
0176 : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
0177
0178
0179
0180
0181
0182
0183 operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
0184
0185
0186
0187 Point3D<double> & operator=(const Point3D<double> &) = default;
0188
0189
0190
0191 Point3D<double> & operator=(const BasicVector3D<float> & v) {
0192 this->BasicVector3D<double>::operator=(v);
0193 return *this;
0194 }
0195
0196
0197
0198 Point3D<double> & operator=(const BasicVector3D<double> & v) {
0199 this->BasicVector3D<double>::operator=(v);
0200 return *this;
0201 }
0202
0203
0204
0205 Point3D<double> & operator=(Point3D<double> &&) = default;
0206
0207
0208
0209 double distance2() const { return mag2(); }
0210
0211
0212
0213 double distance2(const Point3D<double> & p) const {
0214 double dx = p.x()-x(), dy = p.y()-y(), dz = p.z()-z();
0215 return dx*dx + dy*dy + dz*dz;
0216 }
0217
0218
0219
0220 double distance() const { return std::sqrt(distance2()); }
0221
0222
0223
0224 double distance(const Point3D<double> & p) const {
0225 return std::sqrt(distance2(p));
0226 }
0227
0228
0229
0230 Point3D<double> & transform(const Transform3D & m);
0231 };
0232
0233
0234
0235
0236
0237 Point3D<double>
0238 operator*(const Transform3D & m, const Point3D<double> & p);
0239
0240 }
0241
0242 #ifdef ENABLE_BACKWARDS_COMPATIBILITY
0243
0244 #include "CLHEP/config/CLHEP.h"
0245 #include "CLHEP/Geometry/Normal3D.h"
0246 #include "CLHEP/Geometry/Transform3D.h"
0247 typedef HepGeom::Point3D<double> HepPoint3D;
0248 #endif
0249
0250 #endif