Sorry everyone... the line below <div><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">vtkMath::</span><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgb(255, 255, 255); ">Matrix3x3ToQuaternion(styQS, qi);</span></div>
<div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><br></font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif">Should be qs not qi </font></div><div><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><span class="Apple-style-span" style="font-size: 13px; background-color: rgb(255, 255, 255); ">vtkMath::</span></font><font class="Apple-style-span" color="#222222" face="arial, sans-serif"><span class="Apple-style-span" style="font-size: 13px; background-color: rgb(255, 255, 255); ">Matrix3x3ToQuaternion(styQS, qs);</span><br>
</font></div><div><div class="gmail_quote"><br></div><div class="gmail_quote">Sergio </div><div class="gmail_quote"><br></div><div class="gmail_quote">On Thu, Sep 1, 2011 at 8:27 AM, Sergio Aguirre <span dir="ltr"><<a href="mailto:sergio.aguirre@gmail.com">sergio.aguirre@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi everyone.<div><br></div><div>I am trying to rotate a vtkProp3D by using quaternions. </div><div><br></div><div>Basically I have a line (defined by vtkLineSource, mapper & actor) that when its end point is inside the bounds of an object (vtkProp3D) I would like to use to rotate + translate that object following the line. </div>
<div><br></div><div>What I am doing now is: </div><div><br></div><div>Using </div><div>double qs[4], qf[4], qt[4], styQS[3][3], styQF[3][3]; </div><div><br></div><div>1 - Save the initial matrix4x4 (styPoseE) of the line's end point and generate a start-quaternion "qs" a 3x3 matrix using vtkMath tools</div>
<div><br></div><div><div><span style="white-space:pre-wrap">        </span>for (i=0; i<=2; i++)</div><div><span style="white-space:pre-wrap">                </span>for (j=0; j<=2; j++)</div><div><span style="white-space:pre-wrap">                        </span>styQS[j][i] = styPoseE->GetElement(j,i); </div>
<div><span style="white-space:pre-wrap">        </span>vtkMath::Matrix3x3ToQuaternion(styQS, qi);</div></div><div><br></div><div>2 - I sample the line's movement and save the end matrix4x4 of the line's end point in an final-quaternion "qf"</div>
<div><br></div><div><div><span style="white-space:pre-wrap">        </span>for (i=0; i<=2; i++)</div><div><span style="white-space:pre-wrap">        </span><span style="white-space:pre-wrap">        </span>for (j=0; j<=2; j++)</div>
<div><span style="white-space:pre-wrap">                        </span>styQF[j][i] = styPoseE->GetElement(j,i); </div><div><span style="white-space:pre-wrap">        </span>vtkMath::Matrix3x3ToQuaternion(styQF, qf);</div>
</div><div><br></div><div>3 - I calculate the conjugate of qs (qs')</div><div><br></div><div><div>qs[1] = -qi[1]; </div><div>qs[2] = -qi[2]; </div><div>qs[3] = -qi[3];</div></div><div><br></div><div>4 - I calculate a quaternion "qt" that describes the rotation that describes the difference between qs and qt by qt = qf * qs'</div>
<div><br></div><div><div>qt[0] = (qf[0]*qs[0] - qf[1]*qs[1] - qf[2]*qs[2] - qf[3]*qs[3]); </div><div>qt[1] = (qf[0]*qs[1] + qf[1]*qs[0] + qf[2]*qs[3] - qf[3]*qs[2]); </div><div>qt[2] = (qf[0]*qs[2] - qf[1]*qs[3] + qf[2]*qs[0] + qf[3]*qs[1]); </div>
<div>qt[3] = (qf[0]*qs[3] + qf[1]*qs[2] - qf[2]*qs[1] + qf[3]*qs[0]);</div></div><div><br></div><div>5 - Also, I change the first element of qt (W) to degrees </div><div><br></div><div>qt[0] = vtkMath::DegreesFromRadians(qt[0]);</div>
<div><br></div><div>6 - I apply the qt quaternion to the vtkProp3D object using ->RotateWXYZ(); </div><div><br></div><div>picked_object->RotateWXYZ(qt[0], qt[1], qt[2], qt[3]); </div><div><br></div><div>However, the end result is not what I had expected. My questions are: </div>
<div><br></div><div>- Does qt = qf * qs' describe the differential rotation between qf and qs? I what to apply only the differential so as to do a "soft pull" rotation of the vtkProp3D object and not have a new orientation defined by the line.</div>
<div>- I had initially passed the vtkMatrix4x4 of the line (styPoseE) to the object (vtkProp3D) either using pokeMatrix or SetUserMatrix and do control the rotation of the object BUT only after its orientation is reset to that of the line and I want to only move it following the line. </div>
<div>- Is there a different approach I should consider? This one just makes the object jitter uncontrollably </div><div><br></div><div>Thank you for any suggestions. </div><div><br><font color="#888888">Sergio</font></div>
</blockquote></div><br></div>