# Matrix - package raytracer.utility; /* * this file contains...

This preview shows pages 1–2. Sign up to view the full content.

package raytracer.utility; /** * this file contains the declaration of the class Matrix * Matrix is a 4 x 4 square matrix that is used to represent affine transformations * we don't need a general m x n matrix * */ public class Matrix { public double[][] m = new double[4][4]; // elements // ----------------------------------------------------------------------- default constructor // a default matrix is an identity matrix public Matrix() { for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) { if (x == y) m[x][y] = 1.0; else m[x][y] = 0.0; } } // ----------------------------------------------------------------------- copy constructor public Matrix (Matrix mat) { for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) m[x][y] = mat.m[x][y]; } // ----------------------------------------------------------------------- assignment operator public void set (Matrix rhs) { if (this != rhs) { for (int x = 0; x < 4; x++) for (int y = 0; y < 4; y++) m[x][y] = rhs.m[x][y]; } } // -----------------------------------------------------------------------

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/19/2010 for the course CS 390 taught by Professor Hu during the Spring '10 term at Westminster UT.

### Page1 / 3

Matrix - package raytracer.utility; /* * this file contains...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online