Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

FXMat3d.h
Go to the documentation of this file.
1 /********************************************************************************
2 * *
3 * D o u b l e - P r e c i s i o n 3 x 3 M a t r i x *
4 * *
5 *********************************************************************************
6 * Copyright (C) 2003,2006 by Jeroen van der Zijp. All Rights Reserved. *
7 *********************************************************************************
8 * This library is free software; you can redistribute it and/or *
9 * modify it under the terms of the GNU Lesser General Public *
10 * License as published by the Free Software Foundation; either *
11 * version 2.1 of the License, or (at your option) any later version. *
12 * *
13 * This library is distributed in the hope that it will be useful, *
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16 * Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this library; if not, write to the Free Software *
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
21 *********************************************************************************
22 * $Id: FXMat3d.h,v 1.12 2006/01/22 17:58:05 fox Exp $ *
23 ********************************************************************************/
24 #ifndef FXMAT3D_H
25 #define FXMAT3D_H
26 
27 
28 namespace FX {
29 
30 
31 class FXQuatd;
32 
33 
34 /// Double-precision 3x3 matrix
35 class FXAPI FXMat3d {
36 protected:
37  FXVec3d m[3];
38 public:
39 
40  /// Default constructor
41  FXMat3d(){}
42 
43  /// Initialize matrix from another matrix
44  FXMat3d(const FXMat3d& other);
45 
46  /// Initialize matrix from scalar
47  FXMat3d(FXdouble w);
48 
49  /// Initialize matrix from components
50  FXMat3d(FXdouble a00,FXdouble a01,FXdouble a02,
51  FXdouble a10,FXdouble a11,FXdouble a12,
52  FXdouble a20,FXdouble a21,FXdouble a22);
53 
54  /// Initialize matrix from three vectors
55  FXMat3d(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c);
56 
57  /// Initialize matrix from quaternion
58  FXMat3d(const FXQuatd& quat);
59 
60  /// Assignment
61  FXMat3d& operator=(const FXMat3d& other);
62  FXMat3d& operator=(FXdouble w);
63 
64  /// Set value from another matrix
65  FXMat3d& set(const FXMat3d& other);
66 
67  /// Set value from scalar
68  FXMat3d& set(FXdouble w);
69 
70  /// Set value from components
71  FXMat3d& set(FXdouble a00,FXdouble a01,FXdouble a02,
72  FXdouble a10,FXdouble a11,FXdouble a12,
73  FXdouble a20,FXdouble a21,FXdouble a22);
74 
75  /// Set value from three vectors
76  FXMat3d& set(const FXVec3d& a,const FXVec3d& b,const FXVec3d& c);
77 
78  /// Set value from quaternion
79  FXMat3d& set(const FXQuatd& quat);
80 
81  /// Assignment operators
82  FXMat3d& operator+=(const FXMat3d& w);
83  FXMat3d& operator-=(const FXMat3d& w);
84  FXMat3d& operator*=(FXdouble w);
85  FXMat3d& operator*=(const FXMat3d& w);
86  FXMat3d& operator/=(FXdouble w);
87 
88  /// Indexing
89  FXVec3d& operator[](FXint i){return m[i];}
90  const FXVec3d& operator[](FXint i) const {return m[i];}
91 
92  /// Conversion
93  operator FXdouble*(){return m[0];}
94  operator const FXdouble*() const {return m[0];}
95 
96  /// Unary minus
97  FXMat3d operator-() const;
98 
99  /// Matrix and matrix
100  FXMat3d operator+(const FXMat3d& w) const;
101  FXMat3d operator-(const FXMat3d& w) const;
102  FXMat3d operator*(const FXMat3d& w) const;
103 
104  /// Multiply matrix and vector
105  FXVec3d operator*(const FXVec3d& v) const;
106  FXVec2d operator*(const FXVec2d& v) const;
107 
108  /// Matrix and scalar
109  friend FXAPI FXMat3d operator*(FXdouble x,const FXMat3d& a);
110  friend FXAPI FXMat3d operator*(const FXMat3d& a,FXdouble x);
111  friend FXAPI FXMat3d operator/(const FXMat3d& a,FXdouble x);
112  friend FXAPI FXMat3d operator/(FXdouble x,const FXMat3d& a);
113 
114  /// Set identity matrix
115  FXMat3d& eye();
116 
117  /// Multiply by rotation of phi
118  FXMat3d& rot(FXdouble c,FXdouble s);
119  FXMat3d& rot(FXdouble phi);
120 
121  /// Multiply by translation
122  FXMat3d& trans(FXdouble tx,FXdouble ty);
123 
124  /// Multiply by scaling
125  FXMat3d& scale(FXdouble sx,FXdouble sy);
126  FXMat3d& scale(FXdouble s);
127 
128  /// Determinant
129  FXdouble det() const;
130 
131  /// Transpose
132  FXMat3d transpose() const;
133 
134  /// Invert
135  FXMat3d invert() const;
136 
137  /// Save to a stream
138  friend FXAPI FXStream& operator<<(FXStream& store,const FXMat3d& m);
139 
140  /// Load from a stream
141  friend FXAPI FXStream& operator>>(FXStream& store,FXMat3d& m);
142  };
143 
144 extern FXAPI FXMat3d operator*(FXdouble x,const FXMat3d& a);
145 extern FXAPI FXMat3d operator*(const FXMat3d& a,FXdouble x);
146 extern FXAPI FXMat3d operator/(const FXMat3d& a,FXdouble x);
147 extern FXAPI FXMat3d operator/(FXdouble x,const FXMat3d& a);
148 
149 extern FXAPI FXStream& operator<<(FXStream& store,const FXMat3d& m);
150 extern FXAPI FXStream& operator>>(FXStream& store,FXMat3d& m);
151 
152 }
153 
154 #endif
FXMat3d operator/(const FXMat3d &a, FXdouble x)
FXStream & operator>>(FXStream &store, FXDate &d)
Double-precision quaternion.
Definition: FXQuatd.h:35
Double-precision 3-element vector.
Definition: FXVec3d.h:36
#define FXAPI
Definition: fxdefs.h:122
double FXdouble
Definition: fxdefs.h:399
Definition: FX4Splitter.h:31
int FXint
Definition: fxdefs.h:397
FXDate operator+(const FXDate &d, FXint x)
Definition: FXDate.h:148
FXint operator-(const FXDate &a, const FXDate &b)
Definition: FXDate.h:150
Double-precision 3x3 matrix.
Definition: FXMat3d.h:35
FXStream & operator<<(FXStream &store, const FXDate &d)
FXMat3d operator*(FXdouble x, const FXMat3d &a)

Copyright © 1997-2005 Jeroen van der Zijp