Skip to content

Commit

Permalink
ENH: Make tolerances on angle verification parametrizable
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Rit committed Dec 16, 2022
1 parent cfcf604 commit fac3f64
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 11 additions & 0 deletions include/rtkThreeDCircularProjectionGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ class RTK_EXPORT ThreeDCircularProjectionGeometry : public ProjectionGeometry<3>
itkGetConstMacro(RadiusCylindricalDetector, double);
itkSetMacro(RadiusCylindricalDetector, double);

/** Accessor for the internal tolerance on angles. */
itkGetConstMacro(VerifyAnglesTolerance, double);
itkSetMacro(VerifyAnglesTolerance, double);

itkGetConstMacro(FixAnglesTolerance, double);
itkSetMacro(FixAnglesTolerance, double);

protected:
ThreeDCircularProjectionGeometry();
~ThreeDCircularProjectionGeometry() override = default;
Expand Down Expand Up @@ -476,6 +483,10 @@ class RTK_EXPORT ThreeDCircularProjectionGeometry : public ProjectionGeometry<3>
std::vector<Superclass::MatrixType> m_MagnificationMatrices;
std::vector<ThreeDHomogeneousMatrixType> m_RotationMatrices;
std::vector<ThreeDHomogeneousMatrixType> m_SourceTranslationMatrices;

/** Internal tolerance parameters. */
double m_VerifyAnglesTolerance{ 1e-4 };
double m_FixAnglesTolerance{ 1e-6 };
};
} // namespace rtk

Expand Down
6 changes: 2 additions & 4 deletions src/rtkThreeDCircularProjectionGeometry.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,6 @@ rtk::ThreeDCircularProjectionGeometry::VerifyAngles(const double outOfP
using EulerType = itk::Euler3DTransform<double>;

const Matrix3x3Type & rm = referenceMatrix; // shortcut
const double EPSILON = 1e-4; // internal tolerance for comparison

EulerType::Pointer euler = EulerType::New();
euler->SetComputeZYX(false); // ZXY order
Expand All @@ -685,7 +684,7 @@ rtk::ThreeDCircularProjectionGeometry::VerifyAngles(const double outOfP

for (int i = 0; i < 3; i++) // check whether matrices match
for (int j = 0; j < 3; j++)
if (itk::Math::abs(rm[i][j] - m[i][j]) > EPSILON)
if (itk::Math::abs(rm[i][j] - m[i][j]) > m_VerifyAnglesTolerance)
return false;

return true;
Expand All @@ -698,9 +697,8 @@ rtk::ThreeDCircularProjectionGeometry::FixAngles(double & outOfPlan
const Matrix3x3Type & referenceMatrix) const
{
const Matrix3x3Type & rm = referenceMatrix; // shortcut
const double EPSILON = 1e-6; // internal tolerance for comparison

if (itk::Math::abs(itk::Math::abs(rm[2][1]) - 1.) > EPSILON)
if (itk::Math::abs(itk::Math::abs(rm[2][1]) - 1.) > m_FixAnglesTolerance)
{
double oa = NAN, ga = NAN, ia = NAN;

Expand Down

0 comments on commit fac3f64

Please sign in to comment.