EIC 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 
12  const RotationMatrix3D& rotation) {
13  // Get Euler angles for rotation representated by rotZ * rotY * rotX, i.e.
14  // first rotation around x axis, then y axis, last z axis
15  // The elements stored in rotAngles is (rotZ, rotY, rotX)
16  const Vector3D rotAngles = rotation.eulerAngles(2, 1, 0);
17  double sx = std::sin(rotAngles(2));
18  double cx = std::cos(rotAngles(2));
19  double sy = std::sin(rotAngles(1));
20  double cy = std::cos(rotAngles(1));
21  double sz = std::sin(rotAngles(0));
22  double cz = std::cos(rotAngles(0));
23  // rotZ * rotY * rotX =
24  // [ cz*cy cz*sy*sx-cx*sz sz*sx+cz*cx*sy ]
25  // [ cy*sz cz*cx+sz*sy*sx cx*sz*sy-cz*sx ]
26  // [ -sy cy*sx cy*cx ]
27 
28  // Derivative of local x axis w.r.t. (rotX, rotY, rotZ)
29  RotationMatrix3D rotToLocalXAxis = RotationMatrix3D::Zero();
30  rotToLocalXAxis.col(0) = Vector3D(0, 0, 0);
31  rotToLocalXAxis.col(1) = Vector3D(-cz * sy, -sz * sy, -cy);
32  rotToLocalXAxis.col(2) = Vector3D(-sz * cy, cz * cy, 0);
33  // Derivative of local y axis w.r.t. (rotX, rotY, rotZ)
34  RotationMatrix3D rotToLocalYAxis = RotationMatrix3D::Zero();
35  rotToLocalYAxis.col(0) =
36  Vector3D(cz * sy * cx + sz * sx, sz * sy * cx - cz * sx, cy * cx);
37  rotToLocalYAxis.col(1) = Vector3D(cz * cy * sx, sz * cy * sx, -sy * sx);
38  rotToLocalYAxis.col(2) =
39  Vector3D(-sz * sy * sx - cz * cx, cz * sy * sx - sz * cx, 0);
40  // Derivative of local z axis w.r.t. (rotX, rotY, rotZ)
41  RotationMatrix3D rotToLocalZAxis = RotationMatrix3D::Zero();
42  rotToLocalZAxis.col(0) =
43  Vector3D(sz * cx - cz * sy * sx, -sz * sy * sx - cz * cx, -cy * sx);
44  rotToLocalZAxis.col(1) = Vector3D(cz * cy * cx, sz * cy * cx, -sy * cx);
45  rotToLocalZAxis.col(2) =
46  Vector3D(cz * sx - sz * sy * cx, cz * sy * cx + sz * sx, 0);
47 
48  return std::make_tuple(std::move(rotToLocalXAxis), std::move(rotToLocalYAxis),
49  std::move(rotToLocalZAxis));
50 }