OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
7 | 7 |
8 #include "ui/gfx/transform.h" | 8 #include "ui/gfx/transform.h" |
9 | 9 |
10 #include <cmath> | 10 #include <cmath> |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
770 EXPECT_FLOAT_EQ(t * 4 + 1, to.matrix().get(0, 0)) << "i: " << i; | 770 EXPECT_FLOAT_EQ(t * 4 + 1, to.matrix().get(0, 0)) << "i: " << i; |
771 EXPECT_FLOAT_EQ(t * 3 + 1, to.matrix().get(1, 1)) << "i: " << i; | 771 EXPECT_FLOAT_EQ(t * 3 + 1, to.matrix().get(1, 1)) << "i: " << i; |
772 EXPECT_FLOAT_EQ(t * 2 + 1, to.matrix().get(2, 2)) << "i: " << i; | 772 EXPECT_FLOAT_EQ(t * 2 + 1, to.matrix().get(2, 2)) << "i: " << i; |
773 } | 773 } |
774 } | 774 } |
775 | 775 |
776 TEST(XFormTest, BlendSkew) { | 776 TEST(XFormTest, BlendSkew) { |
777 Transform from; | 777 Transform from; |
778 for (int i = 0; i < 2; ++i) { | 778 for (int i = 0; i < 2; ++i) { |
779 Transform to; | 779 Transform to; |
780 to.SkewX(10); | 780 to.Skew(10, 5); |
781 to.SkewY(5); | |
782 double t = i; | 781 double t = i; |
783 Transform expected; | 782 Transform expected; |
784 expected.SkewX(t * 10); | 783 expected.Skew(t * 10, t * 5); |
785 expected.SkewY(t * 5); | |
786 EXPECT_TRUE(to.Blend(from, t)); | 784 EXPECT_TRUE(to.Blend(from, t)); |
787 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); | 785 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); |
788 } | 786 } |
789 } | 787 } |
790 | 788 |
791 TEST(XFormTest, ExtrapolateSkew) { | 789 TEST(XFormTest, ExtrapolateSkew) { |
792 Transform from; | 790 Transform from; |
793 for (int i = -1; i < 2; ++i) { | 791 for (int i = -1; i < 2; ++i) { |
794 Transform to; | 792 Transform to; |
795 to.SkewX(20); | 793 to.Skew(20, 20); |
796 double t = i; | 794 double t = i; |
797 Transform expected; | 795 Transform expected; |
798 expected.SkewX(t * 20); | 796 expected.Skew(t * 20, t * 20); |
799 EXPECT_TRUE(to.Blend(from, t)); | 797 EXPECT_TRUE(to.Blend(from, t)); |
800 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); | 798 EXPECT_TRUE(MatricesAreNearlyEqual(expected, to)); |
801 } | 799 } |
802 } | 800 } |
803 | 801 |
804 #if defined(_WIN64) | 802 #if defined(_WIN64) |
805 // http://crbug.com/406574 | 803 // http://crbug.com/406574 |
806 #define MAYBE_BlendPerspective DISABLED_BlendPerspective | 804 #define MAYBE_BlendPerspective DISABLED_BlendPerspective |
807 #else | 805 #else |
808 #define MAYBE_BlendPerspective BlendPerspective | 806 #define MAYBE_BlendPerspective BlendPerspective |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
899 | 897 |
900 to = Transform(); | 898 to = Transform(); |
901 to.Scale3d(200.0, 100.0, 300.0); | 899 to.Scale3d(200.0, 100.0, 300.0); |
902 to.Blend(from, 1.0); | 900 to.Blend(from, 1.0); |
903 EXPECT_ROW1_EQ(200.0f, 0.0f, 0.0f, 0.0f, to); | 901 EXPECT_ROW1_EQ(200.0f, 0.0f, 0.0f, 0.0f, to); |
904 EXPECT_ROW2_EQ(0.0f, 100.0f, 0.0f, 0.0f, to); | 902 EXPECT_ROW2_EQ(0.0f, 100.0f, 0.0f, 0.0f, to); |
905 EXPECT_ROW3_EQ(0.0f, 0.0f, 300.0f, 0.0f, to); | 903 EXPECT_ROW3_EQ(0.0f, 0.0f, 300.0f, 0.0f, to); |
906 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | 904 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); |
907 } | 905 } |
908 | 906 |
909 TEST(XFormTest, VerifyBlendForSkewX) { | 907 TEST(XFormTest, VerifyBlendForSkew) { |
910 Transform from; | 908 Transform from; |
911 from.SkewX(0.0); | 909 from.Skew(0.0, 0.0); |
912 | 910 |
913 Transform to; | 911 Transform to; |
914 | 912 |
915 to.SkewX(45.0); | 913 to.Skew(45.0, 0.0); |
916 to.Blend(from, 0.0); | 914 to.Blend(from, 0.0); |
917 EXPECT_EQ(from, to); | 915 EXPECT_EQ(from, to); |
918 | 916 |
919 to = Transform(); | 917 to = Transform(); |
920 to.SkewX(45.0); | 918 to.Skew(45.0, 0.0); |
921 to.Blend(from, 0.5); | 919 to.Blend(from, 0.5); |
922 EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to); | 920 EXPECT_ROW1_EQ(1.0f, 0.5f, 0.0f, 0.0f, to); |
923 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); | 921 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); |
924 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | 922 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); |
925 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | 923 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); |
926 | 924 |
927 to = Transform(); | 925 to = Transform(); |
928 to.SkewX(45.0); | 926 to.Skew(45.0, 0.0); |
929 to.Blend(from, 0.25); | 927 to.Blend(from, 0.25); |
930 EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to); | 928 EXPECT_ROW1_EQ(1.0f, 0.25f, 0.0f, 0.0f, to); |
931 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); | 929 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); |
932 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | 930 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); |
933 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | 931 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); |
934 | 932 |
935 to = Transform(); | 933 to = Transform(); |
936 to.SkewX(45.0); | 934 to.Skew(45.0, 0.0); |
937 to.Blend(from, 1.0); | 935 to.Blend(from, 1.0); |
938 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to); | 936 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, to); |
939 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); | 937 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, to); |
940 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | 938 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); |
941 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | 939 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); |
942 } | 940 } |
943 | 941 |
944 TEST(XFormTest, VerifyBlendForSkewY) { | |
945 // NOTE CAREFULLY: Decomposition of skew and rotation terms of the matrix | |
946 // is inherently underconstrained, and so it does not always compute the | |
947 // originally intended skew parameters. The current implementation uses QR | |
948 // decomposition, which decomposes the shear into a rotation + non-uniform | |
949 // scale. | |
950 // | |
951 // It is unlikely that the decomposition implementation will need to change | |
952 // very often, so to get any test coverage, the compromise is to verify the | |
953 // exact matrix that the.Blend() operation produces. | |
954 // | |
955 // This problem also potentially exists for skewX, but the current QR | |
956 // decomposition implementation just happens to decompose those test | |
957 // matrices intuitively. | |
958 // | |
959 // Unfortunately, this case suffers from uncomfortably large precision | |
960 // error. | |
ajuma
2015/09/01 13:25:10
This test and comment still seem to have value. Do
nainar1
2015/09/02 01:43:33
Done.
| |
961 | |
962 Transform from; | |
963 from.SkewY(0.0); | |
964 | |
965 Transform to; | |
966 | |
967 to.SkewY(45.0); | |
968 to.Blend(from, 0.0); | |
969 EXPECT_EQ(from, to); | |
970 | |
971 to = Transform(); | |
972 to.SkewY(45.0); | |
973 to.Blend(from, 0.25); | |
974 EXPECT_ROW1_NEAR(1.0823489449280947471976333, | |
975 0.0464370719145053845178239, | |
976 0.0, | |
977 0.0, | |
978 to, | |
979 LOOSE_ERROR_THRESHOLD); | |
980 EXPECT_ROW2_NEAR(0.2152925909665224513123150, | |
981 0.9541702441750861130032035, | |
982 0.0, | |
983 0.0, | |
984 to, | |
985 LOOSE_ERROR_THRESHOLD); | |
986 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | |
987 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | |
988 | |
989 to = Transform(); | |
990 to.SkewY(45.0); | |
991 to.Blend(from, 0.5); | |
992 EXPECT_ROW1_NEAR(1.1152212925809066312865525, | |
993 0.0676495144007326631996335, | |
994 0.0, | |
995 0.0, | |
996 to, | |
997 LOOSE_ERROR_THRESHOLD); | |
998 EXPECT_ROW2_NEAR(0.4619397844342648662419037, | |
999 0.9519009045724774464858342, | |
1000 0.0, | |
1001 0.0, | |
1002 to, | |
1003 LOOSE_ERROR_THRESHOLD); | |
1004 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | |
1005 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | |
1006 | |
1007 to = Transform(); | |
1008 to.SkewY(45.0); | |
1009 to.Blend(from, 1.0); | |
1010 EXPECT_ROW1_NEAR(1.0, 0.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); | |
1011 EXPECT_ROW2_NEAR(1.0, 1.0, 0.0, 0.0, to, LOOSE_ERROR_THRESHOLD); | |
1012 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, to); | |
1013 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, to); | |
1014 } | |
1015 | |
1016 #if defined(_WIN64) | 942 #if defined(_WIN64) |
1017 // http://crbug.com/406574 | 943 // http://crbug.com/406574 |
1018 #define MAYBE_VerifyBlendForRotationAboutX DISABLED_VerifyBlendForRotationAboutX | 944 #define MAYBE_VerifyBlendForRotationAboutX DISABLED_VerifyBlendForRotationAboutX |
1019 #else | 945 #else |
1020 #define MAYBE_VerifyBlendForRotationAboutX VerifyBlendForRotationAboutX | 946 #define MAYBE_VerifyBlendForRotationAboutX VerifyBlendForRotationAboutX |
1021 #endif | 947 #endif |
1022 TEST(XFormTest, MAYBE_VerifyBlendForRotationAboutX) { | 948 TEST(XFormTest, MAYBE_VerifyBlendForRotationAboutX) { |
1023 // Even though.Blending uses quaternions, axis-aligned rotations should. | 949 // Even though.Blending uses quaternions, axis-aligned rotations should. |
1024 // Blend the same with quaternions or Euler angles. So we can test | 950 // Blend the same with quaternions or Euler angles. So we can test |
1025 // rotation.Blending by comparing against manually specified matrices from | 951 // rotation.Blending by comparing against manually specified matrices from |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1217 // interpolations; order of operations will be tested well enough by the | 1143 // interpolations; order of operations will be tested well enough by the |
1218 // end cases that are easier to specify. | 1144 // end cases that are easier to specify. |
1219 | 1145 |
1220 Transform from; | 1146 Transform from; |
1221 Transform to; | 1147 Transform to; |
1222 | 1148 |
1223 Transform expectedEndOfAnimation; | 1149 Transform expectedEndOfAnimation; |
1224 expectedEndOfAnimation.ApplyPerspectiveDepth(1.0); | 1150 expectedEndOfAnimation.ApplyPerspectiveDepth(1.0); |
1225 expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0); | 1151 expectedEndOfAnimation.Translate3d(10.0, 20.0, 30.0); |
1226 expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0); | 1152 expectedEndOfAnimation.RotateAbout(Vector3dF(0.0, 0.0, 1.0), 25.0); |
1227 expectedEndOfAnimation.SkewY(45.0); | 1153 expectedEndOfAnimation.Skew(0.0, 45.0); |
1228 expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0); | 1154 expectedEndOfAnimation.Scale3d(6.0, 7.0, 8.0); |
1229 | 1155 |
1230 to = expectedEndOfAnimation; | 1156 to = expectedEndOfAnimation; |
1231 to.Blend(from, 0.0); | 1157 to.Blend(from, 0.0); |
1232 EXPECT_EQ(from, to); | 1158 EXPECT_EQ(from, to); |
1233 | 1159 |
1234 to = expectedEndOfAnimation; | 1160 to = expectedEndOfAnimation; |
1235 // We short circuit if blend is >= 1, so to check the numerics, we will | 1161 // We short circuit if blend is >= 1, so to check the numerics, we will |
1236 // check that we get close to what we expect when we're nearly done | 1162 // check that we get close to what we expect when we're nearly done |
1237 // interpolating. | 1163 // interpolating. |
(...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1922 InitializeTestMatrix(&A); | 1848 InitializeTestMatrix(&A); |
1923 A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 35.0); | 1849 A.RotateAbout(Vector3dF(0.0, 0.0, 0.0), 35.0); |
1924 | 1850 |
1925 // Verify that A remains unchanged. | 1851 // Verify that A remains unchanged. |
1926 EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, A); | 1852 EXPECT_ROW1_EQ(10.0f, 14.0f, 18.0f, 22.0f, A); |
1927 EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, A); | 1853 EXPECT_ROW2_EQ(11.0f, 15.0f, 19.0f, 23.0f, A); |
1928 EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, A); | 1854 EXPECT_ROW3_EQ(12.0f, 16.0f, 20.0f, 24.0f, A); |
1929 EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A); | 1855 EXPECT_ROW4_EQ(13.0f, 17.0f, 21.0f, 25.0f, A); |
1930 } | 1856 } |
1931 | 1857 |
1932 TEST(XFormTest, verifySkewX) { | 1858 TEST(XFormTest, verifySkew) { |
1933 Transform A; | 1859 Transform A; |
1934 A.SkewX(45.0); | 1860 A.Skew(45.0, 0.0); |
1935 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); | 1861 EXPECT_ROW1_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); |
1936 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); | 1862 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); |
1937 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); | 1863 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); |
1938 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); | 1864 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); |
1939 | 1865 |
1940 // Verify that skewX() post-multiplies the existing matrix. Row 1, column 2, | 1866 // Verify that skewX() post-multiplies the existing matrix. Row 1, column 2, |
1941 // would incorrectly have value "7" if the matrix is pre-multiplied instead | 1867 // would incorrectly have value "7" if the matrix is pre-multiplied instead |
1942 // of post-multiplied. | 1868 // of post-multiplied. |
1943 A.MakeIdentity(); | 1869 A.MakeIdentity(); |
1944 A.Scale3d(6.0, 7.0, 8.0); | 1870 A.Scale3d(6.0, 7.0, 8.0); |
1945 A.SkewX(45.0); | 1871 A.Skew(45.0, 0.0); |
1946 EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A); | 1872 EXPECT_ROW1_EQ(6.0f, 6.0f, 0.0f, 0.0f, A); |
1947 EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A); | 1873 EXPECT_ROW2_EQ(0.0f, 7.0f, 0.0f, 0.0f, A); |
1948 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); | 1874 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); |
1949 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); | 1875 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); |
ajuma
2015/09/01 13:25:10
Please also test the case where we're skewing alon
nainar1
2015/09/02 01:43:33
Done.
| |
1950 } | 1876 } |
1951 | 1877 |
1952 TEST(XFormTest, verifySkewY) { | |
1953 Transform A; | |
1954 A.SkewY(45.0); | |
1955 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); | |
1956 EXPECT_ROW2_EQ(1.0f, 1.0f, 0.0f, 0.0f, A); | |
1957 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); | |
1958 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); | |
1959 | |
1960 // Verify that skewY() post-multiplies the existing matrix. Row 2, column 1 , | |
1961 // would incorrectly have value "6" if the matrix is pre-multiplied instead | |
1962 // of post-multiplied. | |
1963 A.MakeIdentity(); | |
1964 A.Scale3d(6.0, 7.0, 8.0); | |
1965 A.SkewY(45.0); | |
1966 EXPECT_ROW1_EQ(6.0f, 0.0f, 0.0f, 0.0f, A); | |
1967 EXPECT_ROW2_EQ(7.0f, 7.0f, 0.0f, 0.0f, A); | |
1968 EXPECT_ROW3_EQ(0.0f, 0.0f, 8.0f, 0.0f, A); | |
1969 EXPECT_ROW4_EQ(0.0f, 0.0f, 0.0f, 1.0f, A); | |
1970 } | |
1971 | |
1972 TEST(XFormTest, verifyPerspectiveDepth) { | 1878 TEST(XFormTest, verifyPerspectiveDepth) { |
1973 Transform A; | 1879 Transform A; |
1974 A.ApplyPerspectiveDepth(1.0); | 1880 A.ApplyPerspectiveDepth(1.0); |
1975 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); | 1881 EXPECT_ROW1_EQ(1.0f, 0.0f, 0.0f, 0.0f, A); |
1976 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); | 1882 EXPECT_ROW2_EQ(0.0f, 1.0f, 0.0f, 0.0f, A); |
1977 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); | 1883 EXPECT_ROW3_EQ(0.0f, 0.0f, 1.0f, 0.0f, A); |
1978 EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A); | 1884 EXPECT_ROW4_EQ(0.0f, 0.0f, -1.0f, 1.0f, A); |
1979 | 1885 |
1980 // Verify that PerspectiveDepth() post-multiplies the existing matrix. | 1886 // Verify that PerspectiveDepth() post-multiplies the existing matrix. |
1981 A.MakeIdentity(); | 1887 A.MakeIdentity(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2033 A.Scale3d(6.0, 7.0, 8.0); | 1939 A.Scale3d(6.0, 7.0, 8.0); |
2034 EXPECT_TRUE(A.IsInvertible()); | 1940 EXPECT_TRUE(A.IsInvertible()); |
2035 | 1941 |
2036 A.MakeIdentity(); | 1942 A.MakeIdentity(); |
2037 A.RotateAboutXAxis(10.0); | 1943 A.RotateAboutXAxis(10.0); |
2038 A.RotateAboutYAxis(20.0); | 1944 A.RotateAboutYAxis(20.0); |
2039 A.RotateAboutZAxis(30.0); | 1945 A.RotateAboutZAxis(30.0); |
2040 EXPECT_TRUE(A.IsInvertible()); | 1946 EXPECT_TRUE(A.IsInvertible()); |
2041 | 1947 |
2042 A.MakeIdentity(); | 1948 A.MakeIdentity(); |
2043 A.SkewX(45.0); | 1949 A.Skew(45.0, 0.0); |
2044 EXPECT_TRUE(A.IsInvertible()); | 1950 EXPECT_TRUE(A.IsInvertible()); |
2045 | 1951 |
2046 // A perspective matrix (projection plane at z=0) is invertible. The | 1952 // A perspective matrix (projection plane at z=0) is invertible. The |
2047 // intuitive explanation is that perspective is eqivalent to a skew of the | 1953 // intuitive explanation is that perspective is eqivalent to a skew of the |
2048 // w-axis; skews are invertible. | 1954 // w-axis; skews are invertible. |
2049 A.MakeIdentity(); | 1955 A.MakeIdentity(); |
2050 A.ApplyPerspectiveDepth(1.0); | 1956 A.ApplyPerspectiveDepth(1.0); |
2051 EXPECT_TRUE(A.IsInvertible()); | 1957 EXPECT_TRUE(A.IsInvertible()); |
2052 | 1958 |
2053 // A "pure" perspective matrix derived by similar triangles, with m44() set | 1959 // A "pure" perspective matrix derived by similar triangles, with m44() set |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2693 // Rounding should only affect 2d translation components. | 2599 // Rounding should only affect 2d translation components. |
2694 translation.Translate3d(0.f, 0.f, 0.5f); | 2600 translation.Translate3d(0.f, 0.f, 0.5f); |
2695 expected.Translate3d(0.f, 0.f, 0.5f); | 2601 expected.Translate3d(0.f, 0.f, 0.5f); |
2696 translation.RoundTranslationComponents(); | 2602 translation.RoundTranslationComponents(); |
2697 EXPECT_EQ(expected.ToString(), translation.ToString()); | 2603 EXPECT_EQ(expected.ToString(), translation.ToString()); |
2698 } | 2604 } |
2699 | 2605 |
2700 } // namespace | 2606 } // namespace |
2701 | 2607 |
2702 } // namespace gfx | 2608 } // namespace gfx |
OLD | NEW |