identity_matrix
- compas.geometry.identity_matrix(dim)[source]
Construct an identity matrix.
- Parameters
dim (int) – The number of rows and/or columns of the matrix.
- Returns
list of list – A list of
dim
lists, with each list containingdim
elements. The items on the “diagonal” are one. All other items are zero.
Examples
>>> identity_matrix(4) [[1.0, 0.0, 0.0, 0.0], [0.0, 1.0, 0.0, 0.0], [0.0, 0.0, 1.0, 0.0], [0.0, 0.0, 0.0, 1.0]]