14 float ma = mag(), dz = z();
15 if (ma == 0)
return 0;
18 return 0.5*std::log((ma+dz)/(ma-dz));
26 double tanHalfTheta = std::exp(-a);
27 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
28 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
29 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
31 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
38 double ptot = mag()*v.
mag();
41 if(cosa > 1) cosa = 1;
42 if(cosa < -1) cosa = -1;
44 return std::acos(cosa);
50 double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
51 setY(dy*cosa-dz*sina);
52 setZ(dz*cosa+dy*sina);
59 double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
60 setZ(dz*cosa-dx*sina);
61 setX(dx*cosa+dz*sina);
68 double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
69 setX(dx*cosa-dy*sina);
70 setY(dy*cosa+dx*sina);
78 if (a == 0)
return *
this;
79 double cx = v.
x(), cy = v.
y(), cz = v.
z();
80 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
82 std::cerr <<
"BasicVector<float>::rotate() : zero axis" << std::endl;
85 double cosa = std::cos(a), sina = std::sin(a);
86 cx /= ll; cy /= ll; cz /= ll;
88 double xx = cosa + (1-cosa)*cx*cx;
89 double xy = (1-cosa)*cx*cy - sina*cz;
90 double xz = (1-cosa)*cx*cz + sina*cy;
92 double yx = (1-cosa)*cy*cx + sina*cz;
93 double yy = cosa + (1-cosa)*cy*cy;
94 double yz = (1-cosa)*cy*cz - sina*cx;
96 double zx = (1-cosa)*cz*cx - sina*cy;
97 double zy = (1-cosa)*cz*cy + sina*cx;
98 double zz = cosa + (1-cosa)*cz*cz;
100 cx = x(); cy = y(); cz = z();
101 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
109 return os <<
"(" << a.
x() <<
"," << a.
y() <<
"," << a.
z() <<
")";
126 if (is.fail() || c !=
'(' ) {
128 <<
"Could not find required opening parenthesis "
129 <<
"in input of a BasicVector3D<float>"
134 is >> x >> std::ws >> c;
135 if (is.fail() || c !=
',' ) {
137 <<
"Could not find x value and required trailing comma "
138 <<
"in input of a BasicVector3D<float>"
143 is >> y >> std::ws >> c;
144 if (is.fail() || c !=
',' ) {
146 <<
"Could not find y value and required trailing comma "
147 <<
"in input of a BasicVector3D<float>"
152 is >> z >> std::ws >> c;
153 if (is.fail() || c !=
')' ) {
155 <<
"Could not find z value and required close parenthesis "
156 <<
"in input of a BasicVector3D<float>"
170 double ma = mag(), dz = z();
171 if (ma == 0)
return 0;
173 if (ma == -dz)
return -
DBL_MAX;
174 return 0.5*std::log((ma+dz)/(ma-dz));
182 double tanHalfTheta = std::exp(-a);
183 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
184 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
185 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
187 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
194 double ptot = mag()*v.
mag();
197 if(cosa > 1) cosa = 1;
198 if(cosa < -1) cosa = -1;
200 return std::acos(cosa);
206 double sina = std::sin(a), cosa = std::cos(a), dy = y(), dz = z();
207 setY(dy*cosa-dz*sina);
208 setZ(dz*cosa+dy*sina);
215 double sina = std::sin(a), cosa = std::cos(a), dz = z(), dx = x();
216 setZ(dz*cosa-dx*sina);
217 setX(dx*cosa+dz*sina);
224 double sina = std::sin(a), cosa = std::cos(a), dx = x(), dy = y();
225 setX(dx*cosa-dy*sina);
226 setY(dy*cosa+dx*sina);
234 if (a == 0)
return *
this;
235 double cx = v.
x(), cy = v.
y(), cz = v.
z();
236 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
238 std::cerr <<
"BasicVector<double>::rotate() : zero axis" << std::endl;
241 double cosa = std::cos(a), sina = std::sin(a);
242 cx /= ll; cy /= ll; cz /= ll;
244 double xx = cosa + (1-cosa)*cx*cx;
245 double xy = (1-cosa)*cx*cy - sina*cz;
246 double xz = (1-cosa)*cx*cz + sina*cy;
248 double yx = (1-cosa)*cy*cx + sina*cz;
249 double yy = cosa + (1-cosa)*cy*cy;
250 double yz = (1-cosa)*cy*cz - sina*cx;
252 double zx = (1-cosa)*cz*cx - sina*cy;
253 double zy = (1-cosa)*cz*cy + sina*cx;
254 double zz = cosa + (1-cosa)*cz*cz;
256 cx = x(); cy = y(); cz = z();
257 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
265 return os <<
"(" << a.
x() <<
"," << a.
y() <<
"," << a.
z() <<
")";
282 if (is.fail() || c !=
'(' ) {
284 <<
"Could not find required opening parenthesis "
285 <<
"in input of a BasicVector3D<double>"
290 is >> x >> std::ws >> c;
291 if (is.fail() || c !=
',' ) {
293 <<
"Could not find x value and required trailing comma "
294 <<
"in input of a BasicVector3D<double>"
299 is >> y >> std::ws >> c;
300 if (is.fail() || c !=
',' ) {
302 <<
"Could not find y value and required trailing comma "
303 <<
"in input of a BasicVector3D<double>"
308 is >> z >> std::ws >> c;
309 if (is.fail() || c !=
')' ) {
311 <<
"Could not find z value and required close parenthesis "
312 <<
"in input of a BasicVector3D<double>"
BasicVector3D< T > & rotateZ(T a)
BasicVector3D< T > & rotateX(T a)
BasicVector3D< T > & rotate(T a, const BasicVector3D< T > &v)
T angle(const BasicVector3D< T > &v) const
BasicVector3D< T > & rotateY(T a)
std::istream & operator>>(std::istream &is, BasicVector3D< float > &a)
std::ostream & operator<<(std::ostream &os, const BasicVector3D< float > &a)