STIR 6.5.0
matrix Namespace Reference

Lightweight 3x3 matrix and 3D vector helpers used during PETSIRD geometry analysis. More...

Typedefs

using Mat3 = std::array<std::array<float, 3>, 3>
using Vec3 = std::array<float, 3>

Functions

Mat3 transpose (const Mat3 &mat)
 Transpose a 3x3 matrix.
Mat3 subtract (const Mat3 &A, const Mat3 &B)
 Subtract two 3x3 matrices (A - B).
Vec3 getAxisFromSkew (const Mat3 &S)
 Extract rotation axis from the skew-symmetric matrix S = R - R^T.

Detailed Description

Lightweight 3x3 matrix and 3D vector helpers used during PETSIRD geometry analysis.

Provides utilities to:

  • transpose a 3x3 matrix,
  • subtract two 3x3 matrices,
  • extract a rotation axis vector from the skew-symmetric part of a matrix.
  • Mat3: std::array<std::array<float,3>,3> for compact fixed-size storage.
  • Vec3: std::array<float,3> for simple 3D vectors.
  • getAxisFromSkew(): Given S = R - R^T (skew-symmetric part of a rotation matrix R), returns the axis proportional to: (S_z,y - S_y,z)/2, (S_x,z - S_z,x)/2, (S_y,x - S_x,y)/2. For a pure rotation, S encodes the axis direction.
  • These helpers assume small numerical noise; thresholds are handled by callers.
  • No external dependencies; intended for quick geometric inference (e.g., rotation axis detection).
Todo
  • Might worth it to use stir::Arrays here. I started a bit of this work but lots pending. See the test_petsird_info_helpers.cxx for some of the work done so far.
  • The function are moved in ArrayFunctions

Function Documentation

◆ transpose()

Mat3 matrix::transpose ( const Mat3 & mat)
inline

Transpose a 3x3 matrix.

Parameters
matInput matrix.
Returns
Transposed matrix.

References transpose().

Referenced by transpose().

◆ subtract()

Mat3 matrix::subtract ( const Mat3 & A,
const Mat3 & B )
inline

Subtract two 3x3 matrices (A - B).

Parameters
ALeft-hand matrix.
BRight-hand matrix.
Returns
Result of A - B.

References subtract().

Referenced by subtract().

◆ getAxisFromSkew()

Vec3 matrix::getAxisFromSkew ( const Mat3 & S)
inline

Extract rotation axis from the skew-symmetric matrix S = R - R^T.

Parameters
SSkew-symmetric matrix.
Returns
Axis vector proportional to the rotation axis.

References getAxisFromSkew().

Referenced by getAxisFromSkew().