Update ooo320-m1
[ooovba.git] / binfilter / inc / bf_goodies / hmatrix.hxx
blob2b881b5e4541fabdf53646e383ba6d6b538855f3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: hmatrix.hxx,v $
10 * $Revision: 1.5 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _B3D_HMATRIX_HXX
32 #define _B3D_HMATRIX_HXX
34 #ifndef _B3D_POINT4D_HXX
35 #include "point4d.hxx"
36 #endif
38 namespace binfilter {
40 //////////////////////////////////////////////////////////////////////////
41 // external declarations
42 class Matrix3D;
44 /*************************************************************************
46 |* homogene 4x4 matrix
48 \************************************************************************/
50 class Matrix4D
52 private:
53 // Hilfsfunktionen fuer Matrixinvertierung und Determinantenbestimmung
54 BOOL Ludcmp(UINT16 nIndex[], INT16& nParity);
55 void Lubksb(UINT16 nIndex[], Point4D& aVec);
57 protected:
58 Point4D M[4];
60 public:
61 // default: Einheitsmatrix erstellen (Vektoren sind auf 0
62 // initialisiert, der recte Spaltenvektor auf 1)
63 Matrix4D() { M[0][0] = M[1][1] = M[2][2] = 1.0;
64 M[0][3] = M[1][3] = M[2][3] = 0.0; }
66 // constructor using homogen 3x3 matrix
67 Matrix4D(const Matrix3D& rMat);
69 // set to given homogen 3x3 matrix
70 //void SetMatrix(const Matrix3D& rMat);
72 // Zeilenvektor zurueckgeben
73 Point4D& operator[](int nPos) { return M[nPos]; }
74 const Point4D& operator[](int nPos) const { return M[nPos]; }
76 // Spaltenvektor zurueckgeben
77 Point4D GetColumnVector(int nCol) const
78 { return Point4D(M[0][nCol], M[1][nCol], M[2][nCol], M[3][nCol]); }
80 // Auf Einheitsmatrix zuruecksetzen
81 void Identity(void);
83 // Invertierung
84 BOOL Invert();
86 // Zerlegung
87 BOOL Decompose(Vector3D& rScale, Vector3D& rTranslate, Vector3D& rRotate, Vector3D& rShear) const;
89 // Determinante
90 double Determinant();
92 // Transpose
93 void Transpose();
95 // Rotation
96 void RotateX(double fAngle);
97 void RotateY(double fAngle);
98 void RotateZ(double fAngle);
99 void RotateX(double fSin, double fCos );
100 void RotateY(double fSin, double fCos );
101 void RotateZ(double fSin, double fCos );
103 // Translation
104 void Translate(double fX, double fY, double fZ );
105 void Translate(const Vector3D& aTrans);
106 void TranslateZ(double fValue);
108 // Skalierung
109 void Scale(double fX, double fY, double fZ);
110 void Scale(const Vector3D& aScale);
112 // ModelViewMatrix (ViewOrientationMatrix) fuer die Umwandlung
113 // ObjectCoordinates in EyeCoordinates
114 #if defined( ICC ) || defined( GCC )
115 void Orientation(Point4D aVRP = Point4D(0.0,0.0,1.0),
116 Vector3D aVPN = Vector3D(0.0,0.0,1.0),
117 Vector3D aVUP = Vector3D(0.0,1.0,0.0));
118 #else
119 void Orientation(Point4D& aVRP = Point4D(0.0,0.0,1.0),
120 Vector3D& aVPN = Vector3D(0.0,0.0,1.0),
121 Vector3D& aVUP = Vector3D(0.0,1.0,0.0));
122 #endif
123 // Projektionsmatritzen fuer die Umwandlung von EyeCoordinates
124 // auf ClipCoordinates
125 void Frustum(double fLeft = -1.0, double fRight = 1.0,
126 double fBottom = -1.0, double fTop = 1.0,
127 double fNear = 0.001, double fFar = 1.0);
128 void Ortho(double fLeft = -1.0, double fRight = 1.0,
129 double fBottom = -1.0, double fTop = 1.0,
130 double fNear = 0.0, double fFar = 1.0);
132 // Addition, Subtraktion
133 Matrix4D& operator+= (const Matrix4D&);
134 Matrix4D& operator-= (const Matrix4D&);
135 Matrix4D operator+ (const Matrix4D&) const;
136 Matrix4D operator- (const Matrix4D&) const;
138 // Vergleichsoperatoren
139 BOOL operator== (const Matrix4D&) const;
140 BOOL operator!= (const Matrix4D&) const;
142 // Multiplikation, Division mit Konstante
143 Matrix4D& operator*= (double);
144 Matrix4D operator* (double) const;
145 Matrix4D& operator/= (double);
146 Matrix4D operator/ (double) const;
148 // Matritzenmultiplikation von links auf die lokale
149 Matrix4D& operator*= (const Matrix4D&);
150 Matrix4D operator* (const Matrix4D&) const;
152 // Operatoren zur Punkttransformation
153 friend Point4D operator* (const Matrix4D&, const Point4D&);
154 friend Point4D& operator*= (Point4D& rPnt, const Matrix4D& rMat)
155 { return (rPnt = rMat * rPnt); }
157 // Operatoren zur Vektortransformation
158 friend Vector3D operator* (const Matrix4D&, const Vector3D&);
159 friend Vector3D& operator*= (Vector3D& rVec, const Matrix4D& rMat)
160 { return (rVec = rMat * rVec); }
162 // Streamoperatoren
163 friend SvStream& operator>>(SvStream& rIStream, Matrix4D&);
164 friend SvStream& operator<<(SvStream& rOStream, const Matrix4D&);
166 }//end of namespace binfilter
169 #endif // _B3D_HMATRIX_HXX