Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-73951

QVector3D::normalized fails (returns the zero vector) for very-short vectors

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.9.7
    • Qt3D
    • None

    Description

      QVector3D::normalized tests length-squared; if it's "too short" it returns the zero vector. The problem is, "too short" isn't anywhere near where we'd have precision loss. For example, the vector

      {1e-10, 0.5e-10, 0}

      has a well-defined direction, but normalized will return zero.

      I can see having a cutoff when length-squared approaches float32's minimum positive value (~1e-38) so when components have a length on the order of 1e-19, but the threshold now is closer to float epsilon (the smallest number you can add to 1.0f and get a result that's not 1.0f).

      The same is true of the other QVectorND classes and QQuaternion.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            seanharmer Sean Harmer
            benfrantzdalefl benfrantzdalefl
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes