13 float ma = mag(),
dz =
z();
14 if (ma == 0)
return 0;
17 return 0.5*std::log((ma+
dz)/(ma-
dz));
25 double tanHalfTheta = std::exp(-a);
26 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
27 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
28 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
30 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
37 double ptot = mag()*v.
mag();
40 if(cosa > 1) cosa = 1;
41 if(cosa < -1) cosa = -1;
43 return std::acos(cosa);
49 double sina = std::sin(a), cosa = std::cos(a),
dy =
y(),
dz =
z();
50 setY(
dy*cosa-
dz*sina);
51 setZ(
dz*cosa+
dy*sina);
58 double sina = std::sin(a), cosa = std::cos(a),
dz =
z(),
dx =
x();
59 setZ(
dz*cosa-
dx*sina);
60 setX(
dx*cosa+
dz*sina);
67 double sina = std::sin(a), cosa = std::cos(a),
dx =
x(),
dy =
y();
68 setX(
dx*cosa-
dy*sina);
69 setY(
dy*cosa+
dx*sina);
77 if (a == 0)
return *
this;
78 double cx = v.
x(), cy = v.
y(), cz = v.
z();
79 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
81 std::cerr <<
"BasicVector<float>::rotate() : zero axis" << std::endl;
84 double cosa = std::cos(a), sina = std::sin(a);
85 cx /= ll; cy /= ll; cz /= ll;
87 double xx = cosa + (1-cosa)*cx*cx;
88 double xy = (1-cosa)*cx*cy - sina*cz;
89 double xz = (1-cosa)*cx*cz + sina*cy;
91 double yx = (1-cosa)*cy*cx + sina*cz;
92 double yy = cosa + (1-cosa)*cy*cy;
93 double yz = (1-cosa)*cy*cz - sina*cx;
95 double zx = (1-cosa)*cz*cx - sina*cy;
96 double zy = (1-cosa)*cz*cy + sina*cx;
97 double zz = cosa + (1-cosa)*cz*cz;
99 cx =
x(); cy =
y(); cz =
z();
100 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
106 operator<<(std::ostream & os, const BasicVector3D<float> &
a)
108 return os <<
"(" <<
a.x() <<
"," <<
a.y() <<
"," <<
a.z() <<
")";
125 if (is.fail() || c !=
'(' ) {
127 <<
"Could not find required opening parenthesis "
128 <<
"in input of a BasicVector3D<float>"
133 is >> x >> std::ws >>
c;
134 if (is.fail() || c !=
',' ) {
136 <<
"Could not find x value and required trailing comma "
137 <<
"in input of a BasicVector3D<float>"
142 is >> y >> std::ws >>
c;
143 if (is.fail() || c !=
',' ) {
145 <<
"Could not find y value and required trailing comma "
146 <<
"in input of a BasicVector3D<float>"
151 is >> z >> std::ws >>
c;
152 if (is.fail() || c !=
')' ) {
154 <<
"Could not find z value and required close parenthesis "
155 <<
"in input of a BasicVector3D<float>"
169 double ma = mag(),
dz =
z();
170 if (ma == 0)
return 0;
173 return 0.5*std::log((ma+
dz)/(ma-
dz));
181 double tanHalfTheta = std::exp(-a);
182 double tanHalfTheta2 = tanHalfTheta * tanHalfTheta;
183 double cosTheta1 = (1 - tanHalfTheta2) / (1 + tanHalfTheta2);
184 double rh = ma * std::sqrt(1 - cosTheta1*cosTheta1);
186 set(rh*std::cos(ph), rh*std::sin(ph), ma*cosTheta1);
193 double ptot = mag()*v.
mag();
196 if(cosa > 1) cosa = 1;
197 if(cosa < -1) cosa = -1;
199 return std::acos(cosa);
205 double sina = std::sin(a), cosa = std::cos(a),
dy =
y(),
dz =
z();
206 setY(
dy*cosa-
dz*sina);
207 setZ(
dz*cosa+
dy*sina);
214 double sina = std::sin(a), cosa = std::cos(a),
dz =
z(),
dx =
x();
215 setZ(
dz*cosa-
dx*sina);
216 setX(
dx*cosa+
dz*sina);
223 double sina = std::sin(a), cosa = std::cos(a),
dx =
x(),
dy =
y();
224 setX(
dx*cosa-
dy*sina);
225 setY(
dy*cosa+
dx*sina);
233 if (a == 0)
return *
this;
234 double cx = v.
x(), cy = v.
y(), cz = v.
z();
235 double ll = std::sqrt(cx*cx + cy*cy + cz*cz);
237 std::cerr <<
"BasicVector<double>::rotate() : zero axis" << std::endl;
240 double cosa = std::cos(a), sina = std::sin(a);
241 cx /= ll; cy /= ll; cz /= ll;
243 double xx = cosa + (1-cosa)*cx*cx;
244 double xy = (1-cosa)*cx*cy - sina*cz;
245 double xz = (1-cosa)*cx*cz + sina*cy;
247 double yx = (1-cosa)*cy*cx + sina*cz;
248 double yy = cosa + (1-cosa)*cy*cy;
249 double yz = (1-cosa)*cy*cz - sina*cx;
251 double zx = (1-cosa)*cz*cx - sina*cy;
252 double zy = (1-cosa)*cz*cy + sina*cx;
253 double zz = cosa + (1-cosa)*cz*cz;
255 cx =
x(); cy =
y(); cz =
z();
256 set(xx*cx+xy*cy+xz*cz, yx*cx+yy*cy+yz*cz, zx*cx+zy*cy+zz*cz);
262 operator<< (std::ostream & os, const BasicVector3D<double> &
a)
264 return os <<
"(" <<
a.x() <<
"," <<
a.y() <<
"," <<
a.z() <<
")";
281 if (is.fail() || c !=
'(' ) {
283 <<
"Could not find required opening parenthesis "
284 <<
"in input of a BasicVector3D<double>"
289 is >> x >> std::ws >>
c;
290 if (is.fail() || c !=
',' ) {
292 <<
"Could not find x value and required trailing comma "
293 <<
"in input of a BasicVector3D<double>"
298 is >> y >> std::ws >>
c;
299 if (is.fail() || c !=
',' ) {
301 <<
"Could not find y value and required trailing comma "
302 <<
"in input of a BasicVector3D<double>"
307 is >> z >> std::ws >>
c;
308 if (is.fail() || c !=
')' ) {
310 <<
"Could not find z value and required close parenthesis "
311 <<
"in input of a BasicVector3D<double>"