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

Robert Osfield robert.osfield at gmail.com
Wed Sep 2 00:51:56 PDT 2015


Hi Mattias,

On 2 September 2015 at 08:24, Mattias Helsing <helsing72 at gmail.com> wrote:

> 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?
>


For code that used in inner loops I generally prefer to avoid extra
validity checks as these will have noticeable impact on performance.  For
code that is called rarely the cost of the checks is not significant.

There is also the issue of what you do when you find erroneous input.  In
the case of makeRotate being passed zero length vectors the result is
undefined, even if it catches the case one is left with the question of how
to report an undefined value and what to choose as a result.  For zero
length vectors a zero rotation would be appropriate as to do nothing is
probably a reasonable fallback for most applications.

However, you really shouldn't be passing in erroneous data to start with,
hiding problems lower down won't really solve the problem if the problem is
higher in the stack, for you own application this means finding out why you
are passing zero length vectors into makeRotate().

Robert.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20150902/9c624a47/attachment-0003.htm>


More information about the osg-users mailing list