From 9758b89e72c312fa4b6f0ee23482b587ec517666 Mon Sep 17 00:00:00 2001 From: Vivien Delmon Date: Wed, 18 Apr 2012 14:29:51 +0200 Subject: [PATCH] Add GetRotationMatrix2D and GetRotationMatrix wrapper --- common/clitkTransformUtilities.cxx | 12 ++++++++++++ common/clitkTransformUtilities.h | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/common/clitkTransformUtilities.cxx b/common/clitkTransformUtilities.cxx index 069fc70..1228197 100644 --- a/common/clitkTransformUtilities.cxx +++ b/common/clitkTransformUtilities.cxx @@ -37,4 +37,16 @@ GetBackwardAffineMatrix<3>(itk::Array transformParameters) return GetBackwardAffineMatrix3D(transformParameters); } +template <> +itk::Matrix GetRotationMatrix<2>(itk::Array rotationParameters) +{ + return GetRotationMatrix2D(rotationParameters); +} + +template <> +itk::Matrix GetRotationMatrix<3>(itk::Array rotationParameters) +{ + return GetRotationMatrix3D(rotationParameters); +} + } diff --git a/common/clitkTransformUtilities.h b/common/clitkTransformUtilities.h index a6fdd8c..b9a540a 100644 --- a/common/clitkTransformUtilities.h +++ b/common/clitkTransformUtilities.h @@ -38,6 +38,8 @@ namespace clitk template itk::Matrix GetBackwardAffineMatrix(itk::Array transformParameters); itk::Matrix GetRotationMatrix3D(itk::Array rotationParameters); + itk::Matrix GetRotationMatrix2D(itk::Array rotationParameters); + template itk::Matrix GetRotationMatrix(itk::Array rotationParameters); itk::Point GetRotatedPoint3D(itk::Array rotationParameters, itk::Point input); itk::Matrix GetCenteredRotationMatrix3D(itk::Array rotationParameters,itk::Point centerOfRotation); // itk::Matrix GetComposedMatrix3D(itk::Matrix firstTransform, itk::Matrix secondTransform); @@ -166,9 +168,17 @@ namespace clitk matrix[2][2]= cos(rotationParameters[0])*cos(rotationParameters[1]); return matrix; } - - - + + inline itk::Matrix GetRotationMatrix2D(itk::Array rotationParameters) + { + itk::Matrix matrix; + matrix[0][0] = cos(rotationParameters[0]); + matrix[1][0] = sin(rotationParameters[0]); + matrix[0][1] = -matrix[1][0]; + matrix[1][1] = matrix[0][0]; + return matrix; + } + //======================================================================================== inline itk::Point GetRotatedPoint3D(itk::Array rotationParameters, itk::Point input) { -- 2.47.1