Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
Vector3D.h
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id:$
3// ---------------------------------------------------------------------------
4//
5// This file is a part of the CLHEP - a Class Library for High Energy Physics.
6//
7// History:
8// 09.09.96 E.Chernyaev - initial version
9// 12.06.01 E.Chernyaev - CLHEP-1.7: introduction of BasicVector3D to decouple
10// the functionality from CLHEP::Hep3Vector
11// 01.04.03 E.Chernyaev - CLHEP-1.9: template version
12//
13
14#ifndef HEP_VECTOR3D_H
15#define HEP_VECTOR3D_H
16
17#include <iosfwd>
20
21namespace HepGeom {
22
23 class Transform3D;
24
25 /**
26 * Geometrical 3D Vector.
27 * This is just a declaration of the class needed to define
28 * specializations Vector3D<float> and Vector3D<double>.
29 *
30 * @ingroup geometry
31 * @author Evgeni Chernyaev <[email protected]>
32 */
33 template<class T>
34 class Vector3D : public BasicVector3D<T> {};
35
36 /**
37 * Geometrical 3D Vector with components of float type.
38 *
39 * @author Evgeni Chernyaev <[email protected]>
40 * @ingroup geometry
41 */
42 template<>
43 class Vector3D<float> : public BasicVector3D<float> {
44 public:
45 /**
46 * Default constructor. */
48
49 /**
50 * Constructor from three numbers. */
51 Vector3D(float x1, float y1, float z1) : BasicVector3D<float>(x1,y1,z1) {}
52
53 /**
54 * Constructor from array of floats. */
55 explicit Vector3D(const float * a)
56 : BasicVector3D<float>(a[0],a[1],a[2]) {}
57
58 /**
59 * Copy constructor. */
60 Vector3D(const Vector3D<float> & v) : BasicVector3D<float>(v) {}
61
62 /**
63 * Constructor from BasicVector3D<float>. */
65
66 /**
67 * Destructor. */
69
70 /**
71 * Assignment. */
73 set(v.x(),v.y(),v.z()); return *this;
74 }
75
76 /**
77 * Assignment from BasicVector3D<float>. */
79 set(v.x(),v.y(),v.z()); return *this;
80 }
81
82 /**
83 * Transformation by Transform3D. */
84 Vector3D<float> & transform(const Transform3D & m);
85 };
86
87 /**
88 * Transformation of Vector<float> by Transform3D.
89 * @relates Vector3D
90 */
91 Vector3D<float>
92 operator*(const Transform3D & m, const Vector3D<float> & v);
93
94 /**
95 * Geometrical 3D Vector with components of double type.
96 *
97 * @author Evgeni Chernyaev <[email protected]>
98 * @ingroup geometry
99 */
100 template<>
101 class Vector3D<double> : public BasicVector3D<double> {
102 public:
103 /**
104 * Default constructor. */
106
107 /**
108 * Constructor from three numbers. */
109 Vector3D(double x1, double y1, double z1) : BasicVector3D<double>(x1,y1,z1) {}
110
111 /**
112 * Constructor from array of floats. */
113 explicit Vector3D(const float * a)
114 : BasicVector3D<double>(a[0],a[1],a[2]) {}
115
116 /**
117 * Constructor from array of doubles. */
118 explicit Vector3D(const double * a)
119 : BasicVector3D<double>(a[0],a[1],a[2]) {}
120
121 /**
122 * Copy constructor. */
123 Vector3D(const Vector3D<double> & v) : BasicVector3D<double>(v) {}
124
125 /**
126 * Constructor from BasicVector3D<float>. */
127 Vector3D(const BasicVector3D<float> & v) : BasicVector3D<double>(v) {}
128
129 /**
130 * Constructor from BasicVector3D<double>. */
132
133 /**
134 * Destructor. */
136
137 /**
138 * Constructor from CLHEP::Hep3Vector.
139 * This constructor is needed only for backward compatibility and
140 * in principle should be absent.
141 */
143 : BasicVector3D<double>(v.x(),v.y(),v.z()) {}
144
145 /**
146 * Conversion (cast) to CLHEP::Hep3Vector.
147 * This operator is needed only for backward compatibility and
148 * in principle should not exit.
149 */
150 operator CLHEP::Hep3Vector () const { return CLHEP::Hep3Vector(x(),y(),z()); }
151
152 /**
153 * Assignment. */
155 set(v.x(),v.y(),v.z()); return *this;
156 }
157
158 /**
159 * Assignment from BasicVector3D<float>. */
161 set(v.x(),v.y(),v.z()); return *this;
162 }
163
164 /**
165 * Assignment from BasicVector3D<double>. */
167 set(v.x(),v.y(),v.z()); return *this;
168 }
169
170 /**
171 * Transformation by Transform3D. */
172 Vector3D<double> & transform(const Transform3D & m);
173 };
174
175 /**
176 * Transformation of Vector<double> by Transform3D.
177 * @relates Vector3D
178 */
179 Vector3D<double>
180 operator*(const Transform3D & m, const Vector3D<double> & v);
181
182} /* namespace HepGeom */
183
184#endif /* HEP_VECTOR3D_H */
void set(T x1, T y1, T z1)
Vector3D(const CLHEP::Hep3Vector &v)
Definition: Vector3D.h:142
Vector3D< double > & operator=(const Vector3D< double > &v)
Definition: Vector3D.h:154
Vector3D(const BasicVector3D< double > &v)
Definition: Vector3D.h:131
Vector3D< double > & operator=(const BasicVector3D< float > &v)
Definition: Vector3D.h:160
Vector3D(const BasicVector3D< float > &v)
Definition: Vector3D.h:127
Vector3D(const double *a)
Definition: Vector3D.h:118
Vector3D(const Vector3D< double > &v)
Definition: Vector3D.h:123
Vector3D< double > & operator=(const BasicVector3D< double > &v)
Definition: Vector3D.h:166
Vector3D(const float *a)
Definition: Vector3D.h:113
Vector3D(double x1, double y1, double z1)
Definition: Vector3D.h:109
Vector3D< float > & operator=(const Vector3D< float > &v)
Definition: Vector3D.h:72
Vector3D(float x1, float y1, float z1)
Definition: Vector3D.h:51
Vector3D< float > & operator=(const BasicVector3D< float > &v)
Definition: Vector3D.h:78
Vector3D(const BasicVector3D< float > &v)
Definition: Vector3D.h:64
Vector3D(const float *a)
Definition: Vector3D.h:55
Vector3D(const Vector3D< float > &v)
Definition: Vector3D.h:60
Normal3D< float > operator*(const Transform3D &m, const Normal3D< float > &v)
Definition: Normal3D.cc:24