--- old/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/transform/GeneralTransform3D.java 2018-06-15 19:34:55.416198418 +0530 +++ new/modules/javafx.graphics/src/main/java/com/sun/javafx/geom/transform/GeneralTransform3D.java 2018-06-15 19:34:55.084198418 +0530 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -202,7 +202,7 @@ * @return the transformed point */ public Vec3d transform(Vec3d point) { - return transform(point, point); + return transform(new Vec3d(point), point); } /** @@ -220,11 +220,14 @@ * @return the transformed normal */ public Vec3f transformNormal(Vec3f normal, Vec3f normalOut) { - normal.x = (float) (mat[0]*normal.x + mat[1]*normal.y + + if (normalOut == null) { + normalOut = new Vec3f(); + } + normalOut.x = (float) (mat[0]*normal.x + mat[1]*normal.y + mat[2]*normal.z); - normal.y = (float) (mat[4]*normal.x + mat[5]*normal.y + + normalOut.y = (float) (mat[4]*normal.x + mat[5]*normal.y + mat[6]*normal.z); - normal.z = (float) (mat[8]*normal.x + mat[9]*normal.y + + normalOut.z = (float) (mat[8]*normal.x + mat[9]*normal.y + mat[10]*normal.z); return normalOut; } @@ -242,7 +245,7 @@ * @return the transformed normal */ public Vec3f transformNormal(Vec3f normal) { - return transformNormal(normal, normal); + return transformNormal(new Vec3f(normal), normal); } /** --- /dev/null 2018-06-15 15:51:31.848780000 +0530 +++ new/modules/javafx.graphics/src/test/java/test/com/sun/javafx/geom/transform/GeneralTransform3DTest.java 2018-06-15 19:34:56.032198418 +0530 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package test.com.sun.javafx.geom.transform; + +import com.sun.javafx.geom.transform.GeneralTransform3D; +import com.sun.javafx.geom.Vec3d; +import com.sun.javafx.geom.Vec3f; +import static org.junit.Assert.assertEquals; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * This Unit Test covers GeneralTransform3D and some of its calculations. + */ +public class GeneralTransform3DTest { + + static GeneralTransform3D generalTransform3D = new GeneralTransform3D(); + + static double[] mat = new double[] { + 3.7, 0.0, 0.0, 0.0, + 2.9, 0.0, 0.0, 0.0, + 9.1, 0.0, 0.0, 0.0, + 0.0, 0.0, 0.0, 0.0 + }; + + private void equals(Vec3d vec1, Vec3d vec2) { + assertEquals(vec1.x, vec2.x, 0.001); + assertEquals(vec1.y, vec2.y, 0.001); + assertEquals(vec1.z, vec2.z, 0.001); + } + + private void equals(Vec3f vec1, Vec3f vec2) { + assertEquals(vec1.x, vec2.x, 0.001); + assertEquals(vec1.y, vec2.y, 0.001); + assertEquals(vec1.z, vec2.z, 0.001); + } + + @BeforeClass + public static void setUpClass() { + generalTransform3D.set(mat); + } + + @Test + public void testTransform() { + + double x = 10.5; + double y = 15.7; + double z = 20.9; + + Vec3d vec1 = generalTransform3D.transform(new Vec3d(x, y, z), null); + Vec3d vec2 = new Vec3d(); + Vec3d vec3 = generalTransform3D.transform(new Vec3d(x, y, z), vec2); + equals(vec1, vec2); + assertEquals(vec2, vec3); + + Vec3d vec4 = new Vec3d(x, y, z); + Vec3d vec5 = generalTransform3D.transform(vec4); + equals(vec3, vec5); + assertEquals(vec4, vec5); + } + + @Test + public void testTransformNormal() { + + float x = 1.0f; + float y = 1.0f; + float z = 1.0f; + + Vec3f vec1 = generalTransform3D.transformNormal(new Vec3f(x, y, z), null); + Vec3f vec2 = new Vec3f(); + Vec3f vec3 = generalTransform3D.transformNormal(new Vec3f(x, y, z), vec2); + equals(vec1, vec2); + assertEquals(vec2, vec3); + + Vec3f vec4 = new Vec3f(x, y, z); + Vec3f vec5 = generalTransform3D.transformNormal(vec4); + equals(vec3, vec5); + assertEquals(vec4, vec5); + } +}