This repository was archived by the owner on Feb 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -303,7 +303,7 @@ struct Matrix {
303
303
// precision for small and large scales. Instead, check for the common cases
304
304
// and directly return the max scaling factor.
305
305
if (e[0 ][1 ] == 0 && e[1 ][0 ] == 0 ) {
306
- return std::max (e[0 ][0 ], e[1 ][1 ]);
306
+ return std::max (std::abs ( e[0 ][0 ]), std::abs ( e[1 ][1 ]) );
307
307
}
308
308
return std::sqrt (std::max (e[0 ][0 ] * e[0 ][0 ] + e[0 ][1 ] * e[0 ][1 ],
309
309
e[1 ][0 ] * e[1 ][0 ] + e[1 ][1 ] * e[1 ][1 ]));
Original file line number Diff line number Diff line change @@ -161,6 +161,16 @@ TEST(MatrixTest, TransformHomogenous) {
161
161
Vector3 (32 .0f , 33 .0f , 41 .0f ));
162
162
}
163
163
164
+ TEST (MatrixTest, GetMaxBasisXYNegativeScale) {
165
+ Matrix m = Matrix::MakeScale ({-2 , 1 , 1 });
166
+
167
+ EXPECT_EQ (m.GetMaxBasisLengthXY (), 2 );
168
+
169
+ m = Matrix::MakeScale ({1 , -3 , 1 });
170
+
171
+ EXPECT_EQ (m.GetMaxBasisLengthXY (), 3 );
172
+ }
173
+
164
174
// Verifies a translate scale matrix doesn't need to compute sqrt(pow(scale, 2))
165
175
TEST (MatrixTest, GetMaxBasisXYWithLargeAndSmallScalingFactor) {
166
176
Matrix m = Matrix::MakeScale ({2.625e+20 , 2.625e+20 , 1 });
You can’t perform that action at this time.
0 commit comments