Create the identity matrix I - Android java.lang

Android examples for java.lang:Math Matrix

Description

Create the identity matrix I

Demo Code


//package com.java2s;

public class Main {
    /**//from www .jav  a2 s .  c o  m
     * Create the identity matrix I
     * @param matrix The matrix to store the identity matrix in.
     **/
    public static void identity(float[][] matrix) {
        for (int i = 0; i < 4; i++)
            for (int j = 0; j < 4; j++)
                matrix[i][j] = (i == j) ? 1 : 0;
    }
}

Related Tutorials