Skip to content

Commit

Permalink
BUG: fix computation of rotation matrix for axis in Forbild
Browse files Browse the repository at this point in the history
  • Loading branch information
Simon Rit committed Aug 31, 2021
1 parent 8b0197d commit 0191861
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/rtkForbildPhantomFileReader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ ForbildPhantomFileReader::FindVectorInString(const std::string & name, const std
ForbildPhantomFileReader::RotationMatrixType
ForbildPhantomFileReader::ComputeRotationMatrixBetweenVectors(const VectorType & source, const VectorType & dest) const
{
// https://math.stackexchange.com/questions/180418/calculate-rotation-matrix-to-align-vector-a-to-vector-b-in-3d/476311#476311
VectorType s = source / source.GetNorm();
VectorType d = dest / dest.GetNorm();
RotationMatrixType r;
Expand All @@ -426,11 +427,11 @@ ForbildPhantomFileReader::ComputeRotationMatrixBetweenVectors(const VectorType &
ConvexShape::RotationMatrixType vx;
vx.Fill(0.);
vx[0][1] = -v[2];
vx[1][0] = v[2];
vx[0][2] = v[1];
vx[1][0] = v[2];
vx[1][2] = -v[0];
vx[2][0] = -v[1];
vx[1][2] = v[0];
vx[2][1] = -v[0];
vx[2][1] = v[0];
r += vx;
r += vx * vx * 1. / (1. + c);
return r;
Expand Down

0 comments on commit 0191861

Please sign in to comment.