home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Graphics 16,000
/
graphics-16000.iso
/
msdos
/
utils
/
graphtal.lzh
/
Graphtal.Amiga
/
TransMatrix.h
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-20
|
3KB
|
99 lines
/*
* TransMatrix.h - class definition for general 4x3 transformation matrices.
*
* Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
* University of Berne, Switzerland
* Portions Copyright (C) 1990, Jonathan P. Leech
* All rights reserved.
*
* This software may be freely copied, modified, and redistributed
* provided that this copyright notice is preserved on all copies.
*
* You may not distribute this software, in whole or in part, as part of
* any commercial product without the express consent of the authors.
*
* There is no warranty or other guarantee of fitness of this software
* for any purpose. It is provided solely "as is".
*
*/
#ifndef TransMatrix_H
# define TransMatrix_H
#include <iostream.h>
#include "mathutilities.h"
#include "Vector.h"
void SinCos(real alpha, real&, real&);
//___________________________________________________________ TransMatrix
/*
* [ m11 m12 m13 0 ]
* [ m21 m22 m23 0 ] representation of a
* [ m31 m32 m33 0 ] transformation matrix
* [ m41 m42 m43 1 ]
*/
class TransMatrix
{
public:
enum Axis {X, Y, Z};
public:
TransMatrix();
TransMatrix(const Vector&, const Vector&, const Vector&);
TransMatrix(const Vector&, const Vector&, const Vector&, const Vector&);
TransMatrix(const TransMatrix&);
const TransMatrix& operator=(const TransMatrix&);
real& operator()(int i, int j);
real operator()(int i, int j) const;
TransMatrix& operator+=(const TransMatrix&);
TransMatrix& operator-=(const TransMatrix&);
TransMatrix& operator*=(const TransMatrix&);
TransMatrix operator-();
TransMatrix operator+(const TransMatrix&);
TransMatrix operator-(const TransMatrix&);
TransMatrix operator*(const TransMatrix&);
int invert();
void setRotate(const Vector&, real);
TransMatrix& rotate(const Vector&, real);
TransMatrix& rotate(Axis, const real, const real);
TransMatrix& rotate(Axis, const real);
TransMatrix& scale(const real, const real, const real);
TransMatrix& translate(const Vector&);
friend ostream& operator<<(ostream&, const TransMatrix&);
friend Vector operator*(const Vector&, const TransMatrix&);
private:
real m[4][3];
};
inline real& TransMatrix::operator()(int i, int j)
{
#ifndef __OPTIMIZE__
if (i<0 || i>3 || j<0 || j>2)
Error(ERR_PANIC, "TransMatrix::operator(i,j) index out of range");
#endif
return m[i][j];
}
inline real TransMatrix::operator()(int i, int j) const
{
#ifndef __OPTIMIZE__
if (i<0 || i>3 || j<0 || j>2)
Error(ERR_PANIC, "TransMatrix::operator(i,j) index out of range");
#endif
return m[i][j];
}
#endif // TransMatrix_H