MCPcopy Create free account
hub / github.com/PointCloudLibrary/pcl / getRotationMatrix

Method getRotationMatrix

apps/point_cloud_editor/src/trackball.cpp:162–200  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162void
163TrackBall::getRotationMatrix(float (&rot)[MATRIX_SIZE])
164{
165 // This function is based on quaternion_to_R3_rotation from
166 // http://www.boost.org/doc/libs/1_41_0/libs/math/quaternion/HSO3.hpp
167
168 float a = quat_.R_component_1();
169 float b = quat_.R_component_2();
170 float c = quat_.R_component_3();
171 float d = quat_.R_component_4();
172
173 float aa = a*a;
174 float ab = a*b;
175 float ac = a*c;
176 float ad = a*d;
177 float bb = b*b;
178 float bc = b*c;
179 float bd = b*d;
180 float cc = c*c;
181 float cd = c*d;
182 float dd = d*d;
183
184 setIdentity(rot);
185 float n = aa + bb + cc + dd;
186
187 if (n <= std::numeric_limits<float>::epsilon())
188 return;
189
190 // fill the upper 3x3
191 rot[0] = (aa + bb - cc - dd);
192 rot[1] = 2 * (-ad + bc);
193 rot[2] = 2 * (ac + bd);
194 rot[MATRIX_SIZE_DIM+0] = 2 * (ad + bc);
195 rot[MATRIX_SIZE_DIM+1] = (aa - bb + cc - dd);
196 rot[MATRIX_SIZE_DIM+2] = 2 * (-ab + cd);
197 rot[2*MATRIX_SIZE_DIM+0] = 2 * (-ac + bd);
198 rot[2*MATRIX_SIZE_DIM+1] = 2 * (ab + cd);
199 rot[2*MATRIX_SIZE_DIM+2] = (aa - bb - cc + dd);
200}
201
202void
203TrackBall::reset()

Callers 2

updateMethod · 0.80
updateMethod · 0.80

Calls 1

setIdentityFunction · 0.85

Tested by

no test coverage detected