Source: raytracer/matrix.h


Annotated List
Files
Globals
Hierarchy
Index
/* *************************************************************************
                            matrix.h  -  description
                             -------------------
    begin                : Wed Oct 16 2002    
    copyright            : (C) 2002 by Micha Riser
    email                : mriser@gmx.net
 ************************************************************************* */

/* *************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ************************************************************************* */

#ifndef MATRIX_H
#define MATRIX_H

#include "types.h"
#include "vector.h"
#include<cmath>
#include<cstring>

class Vector3;

/**3x3 transformation matrix.
  *@author Micha Riser
  */

class Matrix {

public: // Public attributes
    DBL a[3][3];

public: // Constructors and destructor

    /**Create uninitialized matrix.
      */
    Matrix() {}
    
    /**Create matrix from array.
      *@param d 3x3 array holding the matrix entries
      */
    Matrix(DBL d[3][3]) {memcpy(&d,&a,sizeof(a));}

    /**Create matrix with same entries.
      *@param d value for all elements
      */
    Matrix(int d) {memset(&a,d,sizeof(DBL)*3*3);}

public: // Public methods
    /**Set all matrix entries to zero.
      */
    void zero() {memset(&a,0,sizeof(DBL)*3*3);}

    /**Transpose matrix.
      */
    void transpose();

    /**Matrix multiplication. Calculate A = M*A.
      *@param m the matrix M
      */
    void applyFromLeft(const Matrix &m);

public: // Static methods
    /**Create scaling matrix. Elements of v on the diagonal and zeros elsewhere.
      *@param v x,y,z scaling value
      */
    static Matrix generateScaleMatrix(const Vector3 &v);

    /**Create rotation matrix.
      *@param v x,y,z rotation values in degrees. Rotating is first done around x then
      *around y and finally around z axe
      */
    static Matrix generateRotationMatrix(Vector3 v);
};

#endif

Generated by: micha@laptop on Thu Oct 24 20:25:24 2002, using kdoc 2.0a53.