Uploaded image for project: 'Commons Math'
  1. Commons Math
  2. MATH-846

Rotation constructor does wrong calculation

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Duplicate
    • Affects Version/s: 3.0
    • Fix Version/s: 3.1
    • Labels:
      None
    • Environment:

      Windows java 1.7r5

      Description

      The following code produces the wrong result. The resulting Rotation is does not even hold a normalized quaternion:

      final Vector3D u1 = new Vector3D(1.0, 0.0, 0.0);
      final Vector3D u2 = new Vector3D(1.0, -1.0, 0.0);
      final Vector3D v1 = new Vector3D(0.9999999, 0., 0.0);
      final Vector3D v2 = new Vector3D(0., 1., 0.0);
      final Rotation rot = new Rotation(u1, u2, v1, v2);
      System.err.println("rot quaternion: " + rot.getQ0() + " " + rot.getQ1() + " " + rot.getQ2() + " " + rot.getQ3());

      For me it outputs:

      rot quaternion: 0.0 0.0 0.0 -7.450580596923828E-9

      The correct output should have been:

      rot quaternion: 0.0 1.0 0.0 0.0

      The constructor seems to be hitting some kind of numerical instability.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              fhess Frank Hess
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: