Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8205008

GeneralTransform3D transform function with single Vec3d argument wrong results

    Details

    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      I believe this is the root cause of
      https://bugs.openjdk.java.net/browse/JDK-8194727 and
      https://bugs.openjdk.java.net/browse/JDK-8190400

      The javafx camera transform calls GeneralTransform3D transform with a single Vec3d argument. The implementation of this method is to call the two argument version of the function with both args set to point.

      The second argument is supposed to be used to return the result. By setting this to the same object as the input parameter the x coordinate result calculation ends up being used as input to the y coordinate calculation.

              pointOut.x = (float) (mat[0] * point.x + mat[1] * point.y
                      + mat[2] * point.z + mat[3]);
              pointOut.y = (float) (mat[4] * point.x + mat[5] * point.y
                      + mat[6] * point.z + mat[7]);
      if pointOut and point are the same object, then pointOut.y is calculated using pointOut.x rather than the original value of point.x

      The fix should be easy, the single transform arg should call the two arg function with the second arg set to null

      REGRESSION : Last worked in version 8u162

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      the above two linked bug reports show the impact of this bug


      ---------- BEGIN SOURCE ----------
      import static org.hamcrest.CoreMatchers.is;
      import static org.hamcrest.CoreMatchers.sameInstance;
      import static org.junit.Assert.assertThat;

      import org.junit.Test;

      import com.sun.javafx.geom.Vec3d;
      import com.sun.javafx.geom.transform.GeneralTransform3D;

      public class GeneralTransform3DTest {

      @Test
      public void testTransform() {
      GeneralTransform3D generalTransform3D = new GeneralTransform3D();

      double[] mat= new double[] {
      0.0, 3.73, 0.0, 0.0,
      3.736, 0.0, 0.0, 0.0,
      0.0, 0.0, 1.0, 1000,
      0.0, 0.0, 1.0, 1000.0
      };

      generalTransform3D.set(mat);

      double x = -49.63;
      double y = -28.0;
      double z = -50.0;



      Vec3d result1 = generalTransform3D.transform(new Vec3d(x, y, z), null);

      Vec3d result2 = new Vec3d();
      Vec3d result3 = generalTransform3D.transform(new Vec3d(x, y, z), result2);

      Vec3d result4 = generalTransform3D.transform(new Vec3d(x, y, z));

      assertThat(result1.x, is((result2.x)));
      assertThat(result1.y, is((result2.y)));
      assertThat(result1.z, is((result2.z)));

      assertThat(result3, sameInstance(result2));

                  
      assertThat(result3.x, is((result4.x)));
      assertThat(result3.y, is((result4.y))); //This will fail
      assertThat(result3.z, is((result4.z)));
      }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                arapte Ambarish Rapte
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: