[osg-users] Quat::makeRotate potential division by zero

Sebastian Messerschmidt sebastian.messerschmidt at gmx.de
Wed Sep 2 00:56:13 PDT 2015


Hi Matthias,

I second Robert's opinion. Passing a zero-length vector simply causes in 
invalid results to be calculated.
My vote would be towards using an assert, so the user is noticed in 
debug builds about the potentially wrong results.
Thats what some other libraries do to hint invalid parameters in 
mathematical functions at least in checked/debug builds..


Cheers
Sebastian
> Hi
>
> Our team chased down a bug where we passed an invalid rotation vector to:
>
> void osg::Quat::makeRotate(const osg::Vec3d& from, const osg::Vec3d& to)
>
> we passed an all zeroes Vec3d in the from parameter. This is then used
> to normalize the vector, which causes INF values and lots of bad
> things further down the line in our code. I know the bug is in our
> code but I also see that there are divide-by-zero checks made in other
> variations of makeRotate(...). The makeRotate_original even had a
> warning print-out.
>
> I guess it's to old performance vs user-friendliness problem, and
> that's why I wanted to bring it up here before submitting anything.
>
> What do you think?
>
> /Mattias
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org




More information about the osg-users mailing list