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 @@ -151,6 +151,18 @@ impl Transform2D {
151
151
self . glam ( |aff| aff. inverse ( ) )
152
152
}
153
153
154
+ /// Returns the determinant of the basis matrix.
155
+ ///
156
+ /// If the basis is uniformly scaled, then its determinant equals the square of the scale factor.
157
+ ///
158
+ /// A negative determinant means the basis was flipped, so one part of the scale is negative.
159
+ /// A zero determinant means the basis isn't invertible, and is usually considered invalid.
160
+ ///
161
+ /// _Godot equivalent: `Transform2D.determinant()`_
162
+ pub fn determinant ( & self ) -> real {
163
+ self . basis ( ) . determinant ( )
164
+ }
165
+
154
166
/// Returns the transform's rotation (in radians).
155
167
///
156
168
/// _Godot equivalent: `Transform2D.get_rotation()`_
@@ -447,7 +459,7 @@ impl Basis2D {
447
459
}
448
460
449
461
/// Returns the determinant of the matrix.
450
- pub ( crate ) fn determinant ( & self ) -> real {
462
+ pub fn determinant ( & self ) -> real {
451
463
self . glam ( |mat| mat. determinant ( ) )
452
464
}
453
465
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