[vtkusers] Bug in vtkQuaternion

Mengda Wu wumengda at gmail.com
Thu Dec 5 15:53:51 EST 2013


Hi all,

   I think there is a bug in vtkQuaternion<T>::SetRotationAngleAndAxis.
What if I want to
set angle=1.0 and xyz=(0, 0, 0)? I need an identity matrix from this
quaternion. Should it call this->Set(1.0, 0.0, 0.0, 0.0) instead of
this->Set(0.0, 0.0, 0.0, 0.0) in this case?

Thanks,
Mengda



The code is pasted here:

template<typename T> void
vtkQuaternion<T>::SetRotationAngleAndAxis (const T& angle,
                                           const T& x,
                                           const T& y,
                                           const T& z)
{
  T axisNorm = x*x + y*y + z*z;
  if (axisNorm != 0.0)
    {
    T w = cos(angle / 2.0);
    this->SetW(w);

    T f = sin( angle / 2.0);
    this->SetX((x / axisNorm) * f);
    this->SetY((y / axisNorm) * f);
    this->SetZ((z / axisNorm) * f);
    }
  else
    {
    this->Set(0.0, 0.0, 0.0, 0.0);
    }
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20131205/9942565d/attachment.htm>


More information about the vtkusers mailing list