Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AlignmentHelper.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AlignmentHelper.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2020 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
11 #include <algorithm>
12 #include <cmath>
13 #include <utility>
14 
16  const RotationMatrix3& rotation) {
17  // Get Euler angles for rotation represented by rotZ * rotY * rotX, i.e.
18  // first rotation around x axis, then y axis, last z axis
19  // The elements stored in rotAngles is (rotZ, rotY, rotX)
20  const Vector3 rotAngles = rotation.eulerAngles(2, 1, 0);
21  double sx = std::sin(rotAngles(2));
22  double cx = std::cos(rotAngles(2));
23  double sy = std::sin(rotAngles(1));
24  double cy = std::cos(rotAngles(1));
25  double sz = std::sin(rotAngles(0));
26  double cz = std::cos(rotAngles(0));
27  // rotZ * rotY * rotX =
28  // [ cz*cy cz*sy*sx-cx*sz sz*sx+cz*cx*sy ]
29  // [ cy*sz cz*cx+sz*sy*sx cx*sz*sy-cz*sx ]
30  // [ -sy cy*sx cy*cx ]
31 
32  // Derivative of local x axis w.r.t. (rotX, rotY, rotZ)
33  RotationMatrix3 rotToLocalXAxis = RotationMatrix3::Zero();
34  rotToLocalXAxis.col(0) = Vector3(0, 0, 0);
35  rotToLocalXAxis.col(1) = Vector3(-cz * sy, -sz * sy, -cy);
36  rotToLocalXAxis.col(2) = Vector3(-sz * cy, cz * cy, 0);
37  // Derivative of local y axis w.r.t. (rotX, rotY, rotZ)
38  RotationMatrix3 rotToLocalYAxis = RotationMatrix3::Zero();
39  rotToLocalYAxis.col(0) =
40  Vector3(cz * sy * cx + sz * sx, sz * sy * cx - cz * sx, cy * cx);
41  rotToLocalYAxis.col(1) = Vector3(cz * cy * sx, sz * cy * sx, -sy * sx);
42  rotToLocalYAxis.col(2) =
43  Vector3(-sz * sy * sx - cz * cx, cz * sy * sx - sz * cx, 0);
44  // Derivative of local z axis w.r.t. (rotX, rotY, rotZ)
45  RotationMatrix3 rotToLocalZAxis = RotationMatrix3::Zero();
46  rotToLocalZAxis.col(0) =
47  Vector3(sz * cx - cz * sy * sx, -sz * sy * sx - cz * cx, -cy * sx);
48  rotToLocalZAxis.col(1) = Vector3(cz * cy * cx, sz * cy * cx, -sy * cx);
49  rotToLocalZAxis.col(2) =
50  Vector3(cz * sx - sz * sy * cx, cz * sy * cx + sz * sx, 0);
51 
52  return std::make_tuple(std::move(rotToLocalXAxis), std::move(rotToLocalYAxis),
53  std::move(rotToLocalZAxis));
54 }