ATLAS Offline Software
Loading...
Searching...
No Matches
HEPVis::SbRotation Class Reference

#include <SbRotation.h>

Collaboration diagram for HEPVis::SbRotation:

Public Member Functions

 SbRotation ()
 SbRotation (const SbVec3d &axis, double radians)
 SbRotation (double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double a41, double a42, double a43, double a44)
void multVec (const SbVec3d &src, SbVec3d &dst) const

Private Attributes

SbVec4d m_quat

Detailed Description

Definition at line 35 of file SbRotation.h.

Constructor & Destructor Documentation

◆ SbRotation() [1/3]

HEPVis::SbRotation::SbRotation ( )

Definition at line 46 of file SbRotation.cxx.

51:m_quat(0,0,0,1)
52{
53}

◆ SbRotation() [2/3]

HEPVis::SbRotation::SbRotation ( const SbVec3d & axis,
double radians )

Definition at line 55 of file SbRotation.cxx.

55 {
56 //FIXME : if(axis.length()==0) //throw
57 m_quat[3] = ::cos(radians/2);
58 double sineval = ::sin(radians/2);
59 SbVec3d a = axis;
60 a.normalize();
61 m_quat[0] = a[0] * sineval;
62 m_quat[1] = a[1] * sineval;
63 m_quat[2] = a[2] * sineval;
64}
static Double_t a

◆ SbRotation() [3/3]

HEPVis::SbRotation::SbRotation ( double a11,
double a12,
double a13,
double a14,
double a21,
double a22,
double a23,
double a24,
double a31,
double a32,
double a33,
double a34,
double a41,
double a42,
double a43,
double a44 )

Definition at line 68 of file SbRotation.cxx.

73 {
74
75 double m[4][4] = { { a11, a12, a13, a14 },
76 { a21, a22, a23, a24 },
77 { a31, a32, a33, a34 },
78 { a41, a42, a43, a44 } };
79
80 double scalerow = m[0][0] + m[1][1] + m[2][2];
81
82 if (scalerow > 0.0) {
83 double s = ::sqrt(scalerow + m[3][3]);
84 m_quat[3] = s * 0.5;
85 s = 0.5 / s;
86
87 m_quat[0] = (m[1][2] - m[2][1]) * s;
88 m_quat[1] = (m[2][0] - m[0][2]) * s;
89 m_quat[2] = (m[0][1] - m[1][0]) * s;
90 }
91 else {
92 int i = 0;
93 if (m[1][1] > m[0][0]) i = 1;
94 if (m[2][2] > m[i][i]) i = 2;
95
96 int j = (i+1)%3;
97 int k = (j+1)%3;
98
99 double s = ::sqrt((m[i][i] - (m[j][j] + m[k][k])) + m[3][3]);
100
101 m_quat[i] = s * 0.5;
102 s = 0.5 / s;
103
104 m_quat[3] = (m[j][k] - m[k][j]) * s;
105 m_quat[j] = (m[i][j] + m[j][i]) * s;
106 m_quat[k] = (m[i][k] + m[k][i]) * s;
107 }
108
109 if (m[3][3] != 1.0) {
110 m_quat *= (1.0/::sqrt(m[3][3]));
111 }
112}

Member Function Documentation

◆ multVec()

void HEPVis::SbRotation::multVec ( const SbVec3d & src,
SbVec3d & dst ) const

Definition at line 119 of file SbRotation.cxx.

119 {
120 //SbMatrix mat;
121 //mat.setRotate(*this);
122
123 double x = m_quat[0];
124 double y = m_quat[1];
125 double z = m_quat[2];
126 double w = m_quat[3];
127
128 double matrix[4][4];
129 matrix[0][0] = w*w + x*x - y*y - z*z;
130 matrix[0][1] = 2*x*y + 2*w*z;
131 matrix[0][2] = 2*x*z - 2*w*y;
132 matrix[0][3] = 0;
133
134 matrix[1][0] = 2*x*y-2*w*z;
135 matrix[1][1] = w*w - x*x + y*y - z*z;
136 matrix[1][2] = 2*y*z + 2*w*x;
137 matrix[1][3] = 0;
138
139 matrix[2][0] = 2*x*z + 2*w*y;
140 matrix[2][1] = 2*y*z - 2*w*x;
141 matrix[2][2] = w*w - x*x - y*y + z*z;
142 matrix[2][3] = 0;
143
144 matrix[3][0] = 0;
145 matrix[3][1] = 0;
146 matrix[3][2] = 0;
147 matrix[3][3] = w*w + x*x + y*y + z*z;
148
149 //mat.multVecMatrix(src, dst);
150 //if(SbMatrixP::isIdentity(this->matrix)) { dst = src; return; }
151
152 double* t0 = matrix[0];
153 double* t1 = matrix[1];
154 double* t2 = matrix[2];
155 double* t3 = matrix[3];
156
157 SbVec3d s = src;
158
159 double W = s[0]*t0[3] + s[1]*t1[3] + s[2]*t2[3] + t3[3];
160
161 dst[0] = (s[0]*t0[0] + s[1]*t1[0] + s[2]*t2[0] + t3[0])/W;
162 dst[1] = (s[0]*t0[1] + s[1]*t1[1] + s[2]*t2[1] + t3[1])/W;
163 dst[2] = (s[0]*t0[2] + s[1]*t1[2] + s[2]*t2[2] + t3[2])/W;
164}
static Double_t t0
#define y
#define x
#define z
std::vector< ALFA_RawDataContainer_p1 > t2
std::vector< ALFA_RawDataCollection_p1 > t1
std::vector< LUCID_RawData_p1 > t3

Member Data Documentation

◆ m_quat

SbVec4d HEPVis::SbRotation::m_quat
private

Definition at line 47 of file SbRotation.h.


The documentation for this class was generated from the following files: