[Rock-dev] RigidBodyState detecting invalid orientations

Jakob Schwendner jakob.schwendner at dfki.de
Fri Jun 29 17:41:58 CEST 2012


On 06/29/2012 05:20 PM, Alexander Duda wrote:
> On 06/29/2012 05:02 PM, Javier Hidalgo Carrió wrote:
>> +1
>> Since Orientation is a Eigen::Quaternion we could even use the norm() 
>> method.
>>
>> Javier.
>>
>> Scalar 
>> <http://eigen.tuxfamily.org/dox/classEigen_1_1QuaternionBase.html#a844358c46408e878e60c4026c52eb1e9> 
>> norm 	( 	
>> 	) 	const|[inline]|
>>
>> *Returns:*
>>     the norm of the quaternion's coefficients 
>>
>> *See also:*
>>     QuaternionBase::squaredNorm()
>>     <http://eigen.tuxfamily.org/dox/classEigen_1_1QuaternionBase.html#a8699d72c996ca6cb4673e810fe3a616c>,
>>     MatrixBase::norm()
>>     <http://eigen.tuxfamily.org/dox/classEigen_1_1MatrixBase.html#a0be1b433c65ce9d92c81a4718daf54e5>
>>
>>
>>
> I think you do not gain so much from this functions as you will get a 
> scalar which you have to sum anyway. Do you know if there is a 
> function which checks if the quaternion is valid?
>
> The proposed code was terrible wrong -- so here is the correction
> fabs(ori.w()*ori.w()+ori.x()*ori.x()+ori.y()*ori.y()+ori.z()*ori.z()-1.0) 
> < 1e-6
>
I would also vote for using the norm() function. Its much clearer, less 
error prone, and the sqrt() you save may not be worth the effort. You 
will still have to do what you are doing with the fabs of course.

Jakob

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.dfki.de/pipermail/rock-dev/attachments/20120629/18b938fa/attachment.htm 


More information about the Rock-dev mailing list