Go to the documentation of this file.
12 #pragma implementation
15 #include "CLHEP/Vector/defs.h"
16 #include "CLHEP/Vector/Rotation.h"
17 #include "CLHEP/Units/PhysicalConstants.h"
24 static inline double safe_acos (
double x) {
25 if (std::abs(
x) <= 1.0)
return std::acos(
x);
26 return ( (
x>0) ? 0 : CLHEP::pi );
31 if (
j == 0) {
return xx(); }
32 if (
j == 1) {
return xy(); }
33 if (
j == 2) {
return xz(); }
35 if (
j == 0) {
return yx(); }
36 if (
j == 1) {
return yy(); }
37 if (
j == 2) {
return yz(); }
39 if (
j == 0) {
return zx(); }
40 if (
j == 1) {
return zy(); }
41 if (
j == 2) {
return zz(); }
43 std::cerr <<
"HepRotation subscripting: bad indices "
44 <<
"(" <<
i <<
"," <<
j <<
")" << std::endl;
50 double ll = aaxis.
mag();
52 ZMthrowC (ZMxpvZeroVector(
"HepRotation: zero axis"));
54 double sa = std::sin(
a), ca = std::cos(
a);
55 double dx = aaxis.
x()/ll, dy = aaxis.
y()/ll, dz = aaxis.
z()/ll;
57 ca+(1-ca)*dx*dx, (1-ca)*dx*dy-sa*dz, (1-ca)*dx*dz+sa*dy,
58 (1-ca)*dy*dx+sa*dz, ca+(1-ca)*dy*dy, (1-ca)*dy*dz-sa*dx,
59 (1-ca)*dz*dx-sa*dy, (1-ca)*dz*dy+sa*dx, ca+(1-ca)*dz*dz );
67 double c1 = std::cos(
a);
68 double s1 = std::sin(
a);
80 double c1 = std::cos(
a);
81 double s1 = std::sin(
a);
93 double c1 = std::cos(
a);
94 double s1 = std::sin(
a);
111 if (std::abs(newZ.
x()-w.
x()) > del ||
112 std::abs(newZ.
y()-w.
y()) > del ||
113 std::abs(newZ.
z()-w.
z()) > del ||
114 std::abs(newX.
mag2()-1.) > del ||
115 std::abs(newY.
mag2()-1.) > del ||
116 std::abs(newZ.
mag2()-1.) > del ||
117 std::abs(newX.
dot(newY)) > del ||
118 std::abs(newY.
dot(newZ)) > del ||
119 std::abs(newZ.
dot(newX)) > del) {
120 std::cerr <<
"HepRotation::rotateAxes: bad axis vectors" << std::endl;
124 newX.
y(), newY.
y(), newZ.
y(),
125 newX.
z(), newY.
z(), newZ.
z()));
130 return (
yx() == 0.0 &&
xx() == 0.0) ? 0.0 : std::atan2(
yx(),
xx());
134 return (
yy() == 0.0 &&
xy() == 0.0) ? 0.0 : std::atan2(
yy(),
xy());
138 return (
yz() == 0.0 &&
xz() == 0.0) ? 0.0 : std::atan2(
yz(),
xz());
142 return safe_acos(
zx());
146 return safe_acos(
zy());
150 return safe_acos(
zz());
154 double cosa = 0.5*(
xx()+
yy()+
zz()-1);
155 double cosa1 = 1-cosa;
160 double x=0, y=0, z=0;
161 if (
xx() > cosa)
x = std::sqrt((
xx()-cosa)/cosa1);
162 if (
yy() > cosa) y = std::sqrt((
yy()-cosa)/cosa1);
163 if (
zz() > cosa) z = std::sqrt((
zz()-cosa)/cosa1);
165 if (
xz() <
zx()) y = -y;
166 if (
yx() <
xy()) z = -z;
167 angle = (cosa < -1.) ? std::acos(-1.) : std::acos(cosa);
173 return (
rxx == 1.0 &&
rxy == 0.0 &&
rxz == 0.0 &&
174 ryx == 0.0 &&
ryy == 1.0 &&
ryz == 0.0 &&
175 rzx == 0.0 &&
rzy == 0.0 &&
rzz == 1.0) ? true :
false;
180 else if (
rzy<r.
rzy)
return -1;
else if (
rzy>r.
rzy)
return 1;
181 else if (
rzx<r.
rzx)
return -1;
else if (
rzx>r.
rzx)
return 1;
182 else if (
ryz<r.
ryz)
return -1;
else if (
ryz>r.
ryz)
return 1;
183 else if (
ryy<r.
ryy)
return -1;
else if (
ryy>r.
ryy)
return 1;
184 else if (
ryx<r.
ryx)
return -1;
else if (
ryx>r.
ryx)
return 1;
185 else if (
rxz<r.
rxz)
return -1;
else if (
rxz>r.
rxz)
return 1;
186 else if (
rxy<r.
rxy)
return -1;
else if (
rxy>r.
rxy)
return 1;
187 else if (
rxx<r.
rxx)
return -1;
else if (
rxx>r.
rxx)
return 1;
double dot(const Hep3Vector &) const
static const HepRotation IDENTITY
void getAngleAxis(double &delta, Hep3Vector &axis) const
HepRotation & rotateZ(double delta)
HepRotation & rotate(double delta, const Hep3Vector &axis)
int compare(const HepRotation &r) const
Hep3Vector cross(const Hep3Vector &) const
Issues Concerning the PhysicsVectors CLHEP Vector Merge The merge of ZOOM PhysicsVdectors and the CLHEP Vector package is completed The purpose of this document is to list the major issues that affected the merge of these and where relevant describe the resolutions More detailed documents describe more minor issues General Approach As agreed at the June CLHEP the approach is to combine the features of each ZOOM class with the corresponding CLHEP class expanding the interface to create a single lingua franca of what a Hep3Vector(for example) means. We are not forming SpaceVector as an class derived from Hep3Vector and enhancing it in that way. Another rule imposed by the agreement is to avoid using the Exceptions package(even though that will later go into CLHEP for other uses). A desirable goal is to avoid cluttering the interface and enlarging the code linked in when ordinary CLHEP Vector functionallity is used. To this end
HepRotation & rotateY(double delta)
HepRotation & rotateX(double delta)
any side effects of that construction would occur twice The semantics of throw x
HepRotation & rotateAxes(const Hep3Vector &newX, const Hep3Vector &newY, const Hep3Vector &newZ)
Signatures of Hep3Vector::rotate For equivalent ZOOM axis There is no harm in leaving this axis CLHEP has implemented a first forming an identity then rotating that by axis and angle(in itself quite a task) then douing vector *
HepRotation & transform(const HepRotation &r)
double operator()(int, int) const