NAMD
Matrix4.h
Go to the documentation of this file.
1 /***************************************************************************
2  *cr
3  *cr (C) Copyright 1995-2008 The Board of Trustees of the
4  *cr University of Illinois
6  *cr
7  ***************************************************************************/
8
9 /***************************************************************************
10  * RCS INFORMATION:
11  *
12  * \$RCSfile: Matrix4.h,v \$
13  * \$Author: jim \$ \$Locker: \$ \$State: Exp \$
14  * \$Revision: 1.2 \$ \$Date: 2008/09/17 16:19:54 \$
15  *
16  ***************************************************************************
17  * DESCRIPTION:
18  *
19  * 4 x 4 Matrix, used for a transformation matrix.
20  *
21  ***************************************************************************/
22 #ifndef MATRIX_FOUR_H
23 #define MATRIX_FOUR_H
24
26 class Matrix4 {
27 public:
28  Matrix4(void) { identity(); }
29  Matrix4(double f) { constant(f); }
30  Matrix4(const double *m);
31  Matrix4(const Matrix4& m) { loadmatrix(m); }
32  ~Matrix4(void) {}
33  double mat;
34
36  void multpoint3d (const double, double) const;
37
39  void multnorm3d (const double, double) const;
40
42  void multpoint4d (const double, double) const;
43
45  void identity(void);
46
48  void constant(double);
49
54  int inverse(void);
55
57  void transpose(void);
58
60  void loadmatrix(const Matrix4 &m);
61  Matrix4& operator=(const Matrix4& m) {loadmatrix(m); return *this;}
62
64  void multmatrix(const Matrix4 &);
65
67  void rot(double, char); // angle in degrees
68
70  void rotate_axis(const double axis, double angle);
71
73  void transvec(double x, double y, double z);
74
76  void transvecinv(double x, double y, double z);
77
79  void translate(double, double, double);
80  void translate(double d) { translate(d, d, d); }
81
83  void scale(double, double, double);
84  void scale(double f) { scale(f, f, f); }
85
87  void window(double, double, double, double, double, double);
88
90  void ortho(double, double, double, double, double, double);
91
93  void ortho2(double, double, double, double);
94
101  void lookat(double, double, double, double, double, double, short);
102 };
103
105 void trans_from_rotate(const double mat3, Matrix4 *mat4);
106
108 void print_Matrix4(const Matrix4 *mat4);
109
110 #endif
111
void identity(void)
clears the matrix (resets it to identity)
Definition: Matrix4.C:92
Matrix4 & operator=(const Matrix4 &m)
Definition: Matrix4.h:61
Matrix4(const Matrix4 &m)
copy constructor
Definition: Matrix4.h:31
~Matrix4(void)
destructor
Definition: Matrix4.h:32
void scale(double f)
Definition: Matrix4.h:84
void transvecinv(double x, double y, double z)
apply a rotation such that the given vector is brought along &#39;x&#39;.
Definition: Matrix4.C:261
void multnorm3d(const double, double) const
multiplies a 3D norm (first arg) by the Matrix, returns in second arg
Definition: Matrix4.C:68
Matrix4(void)
identity constructor
Definition: Matrix4.h:28
void multpoint3d(const double, double) const
multiplies a 3D point (first arg) by the Matrix, returns in second arg
Definition: Matrix4.C:41
void lookat(double, double, double, double, double, double, short)
Definition: Matrix4.C:336
void window(double, double, double, double, double, double)
sets this matrix to represent a window perspective
Definition: Matrix4.C:288
void scale(double, double, double)
performs scaling
Definition: Matrix4.C:279
void print_Matrix4(const Matrix4 *mat4)
Print formatted matrix.
Definition: Matrix4.C:379
4x4 matrix class with numerous operators, conversions, etc.
Definition: Matrix4.h:26
gridSize z
void multpoint4d(const double, double) const
multiplies a 4D point (first arg) by the Matrix, returns in second arg
Definition: Matrix4.C:83
void loadmatrix(const Matrix4 &m)
replaces this matrix with the given one
Definition: Matrix4.C:194
int inverse(void)
Definition: Matrix4.C:110
void trans_from_rotate(const double mat3, Matrix4 *mat4)
Transform 3x3 into 4x4 matrix:
Definition: Matrix4.C:369
Matrix4(double f)
const elements constructor
Definition: Matrix4.h:29
void rotate_axis(const double axis, double angle)
apply a rotation around the given vector; angle in radians.
Definition: Matrix4.C:245
void ortho2(double, double, double, double)
sets this matrix to a 2D orthographic matrix
Definition: Matrix4.C:318
double mat
the matrix itself
Definition: Matrix4.h:33
void transvec(double x, double y, double z)
apply a rotation such that &#39;x&#39; is brought along the given vector.
Definition: Matrix4.C:252
void transpose(void)
transposes the matrix
Definition: Matrix4.C:181
void translate(double, double, double)
performs a translation
Definition: Matrix4.C:270
gridSize y
void translate(double d)
Definition: Matrix4.h:80
void rot(double, char)
performs a left-handed rotation around an axis (char == &#39;x&#39;, &#39;y&#39;, or &#39;z&#39;)
Definition: Matrix4.C:215
void multmatrix(const Matrix4 &)
premultiply the matrix by the given matrix, this-&gt;other * this
Definition: Matrix4.C:199
void constant(double)
sets the matrix so all items are the given constant value
Definition: Matrix4.C:102
gridSize x
void ortho(double, double, double, double, double, double)
sets this matrix to a 3D orthographic matrix
Definition: Matrix4.C:303