Matrix.isIdentity

Returns a identity matrix.

struct Matrix(type, int numCols, int numRows)
@property
bool
isIdentity
(
)
if (
(numCols > 1) &&
(numRows > 1)
)

Examples

Unittest identity, isIdentity

1 mat2 m2 = mat2( 1.0f );
2 assert( m2.isIdentity );
3 assert( m2.data == mat2( 1 ).data );
4 
5 m2 = mat2.identity;
6 assert( m2.data == [[ 1.0f, 0.0f ],
7 					[ 0.0f, 1.0f ]] );
8 
9 mat3 m3 = mat3.identity;
10 assert( m3.isIdentity );
11 assert( m3.data == mat3( 1.0f ).data );
12 
13 mat4 m4 = mat4( 2.0f );
14 assert( m4.data == mat4( 2.0f ).data );
15 
16 m4 = mat4.identity;
17 assert( m4.isIdentity );
18 assert( m4.data == [[ 1.0f, 0.0f, 0.0f, 0.0f ],
19 					[ 0.0f, 1.0f, 0.0f, 0.0f ],
20 					[ 0.0f, 0.0f, 1.0f, 0.0f ],
21 					[ 0.0f, 0.0f, 0.0f, 1.0f ]] );
22 assert( m4.data == m4.identity.data );

Meta