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

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

View Full Document Right Arrow Icon
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]; } } // -----------------------------------------------------------------------
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
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 Right Arrow Icon
Ask a homework question - tutors are online