11#include "CLHEP/Vector/defs.h"
12#include "CLHEP/Vector/Rotation.h"
13#include "CLHEP/Units/PhysicalConstants.h"
20static inline double safe_acos (
double x) {
21 if (std::abs(x) <= 1.0)
return std::acos(x);
22 return ( (x>0) ? 0 : CLHEP::pi );
27 if (j == 0) {
return xx(); }
28 if (j == 1) {
return xy(); }
29 if (j == 2) {
return xz(); }
31 if (j == 0) {
return yx(); }
32 if (j == 1) {
return yy(); }
33 if (j == 2) {
return yz(); }
35 if (j == 0) {
return zx(); }
36 if (j == 1) {
return zy(); }
37 if (j == 2) {
return zz(); }
39 std::cerr <<
"HepRotation subscripting: bad indices "
40 <<
"(" << i <<
"," << j <<
")" << std::endl;
46 double ll = aaxis.
mag();
48 ZMthrowC (ZMxpvZeroVector(
"HepRotation: zero axis"));
50 double sa = std::sin(a), ca = std::cos(a);
51 double dx = aaxis.
x()/ll, dy = aaxis.
y()/ll, dz = aaxis.
z()/ll;
53 ca+(1-ca)*dx*dx, (1-ca)*dx*dy-sa*dz, (1-ca)*dx*dz+sa*dy,
54 (1-ca)*dy*dx+sa*dz, ca+(1-ca)*dy*dy, (1-ca)*dy*dz-sa*dx,
55 (1-ca)*dz*dx-sa*dy, (1-ca)*dz*dy+sa*dx, ca+(1-ca)*dz*dz );
63 double c1 = std::cos(a);
64 double s1 = std::sin(a);
76 double c1 = std::cos(a);
77 double s1 = std::sin(a);
89 double c1 = std::cos(a);
90 double s1 = std::sin(a);
107 if (std::abs(newZ.
x()-w.
x()) > del ||
108 std::abs(newZ.
y()-w.
y()) > del ||
109 std::abs(newZ.
z()-w.
z()) > del ||
110 std::abs(newX.
mag2()-1.) > del ||
111 std::abs(newY.
mag2()-1.) > del ||
112 std::abs(newZ.
mag2()-1.) > del ||
113 std::abs(newX.
dot(newY)) > del ||
114 std::abs(newY.
dot(newZ)) > del ||
115 std::abs(newZ.
dot(newX)) > del) {
116 std::cerr <<
"HepRotation::rotateAxes: bad axis vectors" << std::endl;
120 newX.
y(), newY.
y(), newZ.
y(),
121 newX.
z(), newY.
z(), newZ.
z()));
126 return (
yx() == 0.0 &&
xx() == 0.0) ? 0.0 : std::atan2(
yx(),
xx());
130 return (
yy() == 0.0 &&
xy() == 0.0) ? 0.0 : std::atan2(
yy(),
xy());
134 return (
yz() == 0.0 &&
xz() == 0.0) ? 0.0 : std::atan2(
yz(),
xz());
138 return safe_acos(
zx());
142 return safe_acos(
zy());
146 return safe_acos(
zz());
150 double cosa = 0.5*(
xx()+
yy()+
zz()-1);
151 double cosa1 = 1-cosa;
156 double x=0, y=0, z=0;
157 if (
xx() > cosa) x = std::sqrt((
xx()-cosa)/cosa1);
158 if (
yy() > cosa) y = std::sqrt((
yy()-cosa)/cosa1);
159 if (
zz() > cosa) z = std::sqrt((
zz()-cosa)/cosa1);
160 if (
zy() <
yz()) x = -x;
161 if (
xz() <
zx()) y = -y;
162 if (
yx() <
xy()) z = -z;
163 angle = (cosa < -1.) ? std::acos(-1.) : std::acos(cosa);
169 return (
rxx == 1.0 &&
rxy == 0.0 &&
rxz == 0.0 &&
170 ryx == 0.0 &&
ryy == 1.0 &&
ryz == 0.0 &&
171 rzx == 0.0 &&
rzy == 0.0 &&
rzz == 1.0) ? true :
false;
176 else if (
rzy<r.
rzy)
return -1;
else if (
rzy>r.
rzy)
return 1;
177 else if (
rzx<r.
rzx)
return -1;
else if (
rzx>r.
rzx)
return 1;
178 else if (
ryz<r.
ryz)
return -1;
else if (
ryz>r.
ryz)
return 1;
179 else if (
ryy<r.
ryy)
return -1;
else if (
ryy>r.
ryy)
return 1;
180 else if (
ryx<r.
ryx)
return -1;
else if (
ryx>r.
ryx)
return 1;
181 else if (
rxz<r.
rxz)
return -1;
else if (
rxz>r.
rxz)
return 1;
182 else if (
rxy<r.
rxy)
return -1;
else if (
rxy>r.
rxy)
return 1;
183 else if (
rxx<r.
rxx)
return -1;
else if (
rxx>r.
rxx)
return 1;
Hep3Vector cross(const Hep3Vector &) const
double dot(const Hep3Vector &) const
double operator()(int, int) const
HepRotation & rotateAxes(const Hep3Vector &newX, const Hep3Vector &newY, const Hep3Vector &newZ)
HepRotation & rotate(double delta, const Hep3Vector &axis)
HepRotation & transform(const HepRotation &r)
static const HepRotation IDENTITY
void getAngleAxis(double &delta, Hep3Vector &axis) const
HepRotation & rotateX(double delta)
HepRotation & rotateZ(double delta)
HepRotation & rotateY(double delta)
int compare(const HepRotation &r) const