Skip to content

Commit ae12944

Browse files
authored
[math][GenVector] Add access operator for Rotation3D (#18480)
* [GenVector] Add access operator for Rotation3D * [GenVector] Add parameters in documentation
1 parent 138efa6 commit ae12944

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

math/genvector/inc/Math/GenVector/Rotation3D.h

+15
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "Math/GenVector/RotationYfwd.h"
3535
#include "Math/GenVector/RotationZfwd.h"
3636

37+
#include "Math/GenVector/GenVector_exception.h"
3738

3839
#include <algorithm>
3940
#include <cassert>
@@ -345,6 +346,20 @@ class Rotation3D {
345346

346347
// =========== operations ==============
347348

349+
/**
350+
Access operator, used to have direct access to rotation matrix's entries
351+
\param i row index in {0,1,2}
352+
\param j column index in {0,1,2}
353+
*/
354+
Scalar operator()(size_t i, size_t j) const
355+
{
356+
if (i < 3 && j < 3)
357+
return fM[i + 3 * j];
358+
else
359+
GenVector::Throw("Rotation3D::operator(size_t i, size_t j):\n"
360+
" indices i and j must range in {0,1,2}");
361+
return 0.0;
362+
}
348363

349364
/**
350365
Rotation operation on a displacement vector in any coordinate system

0 commit comments

Comments
 (0)