Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _BGFX_MATRIX_B3DHOMMATRIX_HXX
30 : : #define _BGFX_MATRIX_B3DHOMMATRIX_HXX
31 : :
32 : : #include <sal/types.h>
33 : : #include <basegfx/point/b3dpoint.hxx>
34 : : #include <basegfx/vector/b3dvector.hxx>
35 : : #include <o3tl/cow_wrapper.hxx>
36 : : #include <basegfx/basegfxdllapi.h>
37 : :
38 : : namespace basegfx
39 : : {
40 : : class B3DTuple;
41 : : class Impl3DHomMatrix;
42 : :
43 : : class BASEGFX_DLLPUBLIC B3DHomMatrix
44 : : {
45 : : public:
46 : : typedef o3tl::cow_wrapper< Impl3DHomMatrix > ImplType;
47 : :
48 : : private:
49 : : ImplType mpImpl;
50 : :
51 : : public:
52 : : B3DHomMatrix();
53 : : B3DHomMatrix(const B3DHomMatrix& rMat);
54 : : ~B3DHomMatrix();
55 : :
56 : : double get(sal_uInt16 nRow, sal_uInt16 nColumn) const;
57 : : void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue);
58 : :
59 : : // test if last line is default to see if last line needs to be
60 : : // involved in calculations
61 : : bool isLastLineDefault() const;
62 : :
63 : : bool isIdentity() const;
64 : : /// Reset to the identity matrix
65 : : void identity();
66 : :
67 : : /// Invert the matrix (if possible)
68 : : bool invert();
69 : :
70 : : /// Calc the matrix determinant
71 : : double determinant() const;
72 : :
73 : : /// Rotation
74 : : void rotate(double fAngleX,double fAngleY,double fAngleZ);
75 : :
76 : : /// Translation
77 : : void translate(double fX, double fY, double fZ);
78 : :
79 : : /// Scaling
80 : : void scale(double fX, double fY, double fZ);
81 : :
82 : : // Shearing-Matrices
83 : : void shearXY(double fSx, double fSy);
84 : :
85 : : // Projection matrices, used for converting between eye and
86 : : // clip coordinates
87 : : void frustum(double fLeft = -1.0, double fRight = 1.0,
88 : : double fBottom = -1.0, double fTop = 1.0,
89 : : double fNear = 0.001, double fFar = 1.0);
90 : :
91 : : void ortho(double fLeft = -1.0, double fRight = 1.0,
92 : : double fBottom = -1.0, double fTop = 1.0,
93 : : double fNear = 0.0, double fFar = 1.0);
94 : :
95 : : // build orientation matrix
96 : : void orientation(
97 : : B3DPoint aVRP = B3DPoint(0.0,0.0,1.0),
98 : : B3DVector aVPN = B3DVector(0.0,0.0,1.0),
99 : : B3DVector aVUV = B3DVector(0.0,1.0,0.0));
100 : :
101 : : // addition, subtraction
102 : : B3DHomMatrix& operator+=(const B3DHomMatrix& rMat);
103 : : B3DHomMatrix& operator-=(const B3DHomMatrix& rMat);
104 : :
105 : : // comparison
106 : : bool operator==(const B3DHomMatrix& rMat) const;
107 : : bool operator!=(const B3DHomMatrix& rMat) const;
108 : :
109 : : // multiplication, division by constant value
110 : : B3DHomMatrix& operator*=(double fValue);
111 : : B3DHomMatrix& operator/=(double fValue);
112 : :
113 : : // matrix multiplication (from the left)
114 : : B3DHomMatrix& operator*=(const B3DHomMatrix& rMat);
115 : :
116 : : // assignment operator
117 : : B3DHomMatrix& operator=(const B3DHomMatrix& rMat);
118 : :
119 : : // decomposition
120 : : bool decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const;
121 : : };
122 : :
123 : : // addition, subtraction
124 : : inline B3DHomMatrix operator+(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB)
125 : : {
126 : : B3DHomMatrix aSum(rMatA);
127 : : aSum += rMatB;
128 : : return aSum;
129 : : }
130 : :
131 : : inline B3DHomMatrix operator-(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB)
132 : : {
133 : : B3DHomMatrix aDiv(rMatA);
134 : : aDiv -= rMatB;
135 : : return aDiv;
136 : : }
137 : :
138 : : // multiplication, division by constant value
139 : : inline B3DHomMatrix operator*(const B3DHomMatrix& rMat, double fValue)
140 : : {
141 : : B3DHomMatrix aNew(rMat);
142 : : aNew *= fValue;
143 : : return aNew;
144 : : }
145 : :
146 : : inline B3DHomMatrix operator/(const B3DHomMatrix& rMat, double fValue)
147 : : {
148 : : B3DHomMatrix aNew(rMat);
149 : : aNew *= 1.0 / fValue;
150 : : return aNew;
151 : : }
152 : :
153 : 37201 : inline B3DHomMatrix operator*(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB)
154 : : {
155 : 37201 : B3DHomMatrix aMul(rMatB);
156 [ + - ]: 37201 : aMul *= rMatA;
157 : 37201 : return aMul;
158 : : }
159 : : } // end of namespace basegfx
160 : :
161 : : #endif /* _BGFX_MATRIX_B3DHOMMATRIX_HXX */
162 : :
163 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|