File tree 3 files changed +29
-1
lines changed
itest/rust/src/builtin_tests/geometry
3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 23
23
* .bat
24
24
config.toml
25
25
exp.rs
26
+
27
+ # Mac specific
28
+ .DS_Store
Original file line number Diff line number Diff line change @@ -150,6 +150,18 @@ impl Transform2D {
150
150
self . glam ( |aff| aff. inverse ( ) )
151
151
}
152
152
153
+ /// Returns the determinant of the basis matrix.
154
+ ///
155
+ /// If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
156
+ ///
157
+ /// A negative determinant means the basis was flipped, so one part of the scale is negative.
158
+ /// A zero determinant means the basis isn't invertible, and is usually considered invalid.
159
+ ///
160
+ /// _Godot equivalent: `Transform2D.determinant()`_
161
+ pub fn determinant ( & self ) -> real {
162
+ self . basis ( ) . determinant ( )
163
+ }
164
+
153
165
/// Returns the transform's rotation (in radians).
154
166
///
155
167
/// _Godot equivalent: `Transform2D.get_rotation()`_
@@ -443,7 +455,7 @@ impl Basis2D {
443
455
}
444
456
445
457
/// Returns the determinant of the matrix.
446
- pub ( crate ) fn determinant ( & self ) -> real {
458
+ pub fn determinant ( & self ) -> real {
447
459
self . glam ( |mat| mat. determinant ( ) )
448
460
}
449
461
Original file line number Diff line number Diff line change @@ -57,6 +57,19 @@ fn transform2d_equiv() {
57
57
) ;
58
58
}
59
59
60
+ #[ cfg( since_api = "4.1" ) ]
61
+ #[ itest]
62
+ fn transform2d_determinant ( ) {
63
+ let inner = InnerTransform2D :: from_outer ( & TEST_TRANSFORM ) ;
64
+ let outer = TEST_TRANSFORM ;
65
+
66
+ assert_eq_approx ! (
67
+ real:: from_f64( inner. determinant( ) ) ,
68
+ outer. determinant( ) ,
69
+ "function: determinant\n "
70
+ ) ;
71
+ }
72
+
60
73
#[ itest]
61
74
fn transform2d_xform_equiv ( ) {
62
75
let vec = Vector2 :: new ( 1.0 , 2.0 ) ;
You can’t perform that action at this time.
0 commit comments