8 for (
unsigned i=0; i<3; ++i)
9 for (
unsigned j=0; j<3; ++j)
10 R[i][j] = (i==j ? 1 : 0);
13 double u[3] = {x[0], x[1], x[2]};
14 double angle = std::sqrt(u[0]*u[0] + u[1]*u[1] + u[2]*u[2]);
23 for (
unsigned i=0; i<3; ++i)
24 for (
unsigned j=0; j<3; ++j)
25 R[i][j] += (
cos_angle-1) * ((i==j ? 1:0) - u[i]*u[j]);
28 double sin_angle = std::sin(
angle);
29 R[0][1] -= sin_angle*u[2]; R[0][2] += sin_angle*u[1];
30 R[1][0] += sin_angle*u[2]; R[1][2] -= sin_angle*u[0];
31 R[2][0] -= sin_angle*u[1]; R[2][1] += sin_angle*u[0];
38 double *R_[3] = { R[0], R[1], R[2] };
44 double *R[3] = { R0, R1, R2 };
VNL_EXPORT vnl_matrix_fixed< double, 3, 3 > vnl_rotation_matrix(vnl_vector_fixed< double, 3 > const &axis)
Returns an orthogonal 3x3 matrix which is a rotation about the axis, by an angle equal to ||axis||.
Fixed size, stack-stored, space-efficient matrix.
T const *const * data_array() const
Access the 2D array, so that elements can be accessed with array[row][col] directly.
Fixed length stack-stored, space-efficient vector.
Fixed length stack-stored vector.
T angle(const vnl_vector_fixed< T, n > &a, const vnl_vector_fixed< T, n > &b)
Functions to create a 3x3 rotation matrix.
VNL_EXPORT T cos_angle(m const &, m const &)