1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #ifndef INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIX_HXX 21 #define INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIX_HXX 22 23 #include <sal/types.h> 24 #include <basegfx/point/b3dpoint.hxx> 25 #include <basegfx/vector/b3dvector.hxx> 26 #include <o3tl/cow_wrapper.hxx> 27 #include <basegfx/basegfxdllapi.h> 28 29 namespace basegfx 30 { 31 class B3DTuple; 32 class Impl3DHomMatrix; 33 34 class BASEGFX_DLLPUBLIC B3DHomMatrix 35 { 36 public: 37 typedef o3tl::cow_wrapper< Impl3DHomMatrix, o3tl::ThreadSafeRefCountingPolicy > ImplType; 38 39 private: 40 ImplType mpImpl; 41 42 public: 43 B3DHomMatrix(); 44 B3DHomMatrix(const B3DHomMatrix& rMat); 45 B3DHomMatrix(B3DHomMatrix&& rMat); 46 ~B3DHomMatrix(); 47 48 double get(sal_uInt16 nRow, sal_uInt16 nColumn) const; 49 void set(sal_uInt16 nRow, sal_uInt16 nColumn, double fValue); 50 51 // test if last line is default to see if last line needs to be 52 // involved in calculations 53 bool isLastLineDefault() const; 54 55 bool isIdentity() const; 56 /// Reset to the identity matrix 57 void identity(); 58 59 /// Invert the matrix (if possible) 60 void invert(); 61 62 /// Calc the matrix determinant 63 double determinant() const; 64 65 /// Rotation 66 void rotate(double fAngleX,double fAngleY,double fAngleZ); 67 void rotate(const B3DTuple& rRotation); 68 69 /// Translation 70 void translate(double fX, double fY, double fZ); 71 void translate(const B3DTuple& rTranslation); 72 73 /// Scaling 74 void scale(double fX, double fY, double fZ); 75 void scale(const B3DTuple& rScale); 76 77 // Shearing-Matrices 78 void shearXY(double fSx, double fSy); 79 void shearXZ(double fSx, double fSz); 80 81 // Projection matrices, used for converting between eye and 82 // clip coordinates 83 void frustum(double fLeft = -1.0, double fRight = 1.0, 84 double fBottom = -1.0, double fTop = 1.0, 85 double fNear = 0.001, double fFar = 1.0); 86 87 void ortho(double fLeft = -1.0, double fRight = 1.0, 88 double fBottom = -1.0, double fTop = 1.0, 89 double fNear = 0.0, double fFar = 1.0); 90 91 // build orientation matrix 92 void orientation( 93 const B3DPoint& rVRP = B3DPoint(0.0,0.0,1.0), 94 B3DVector aVPN = B3DVector(0.0,0.0,1.0), 95 B3DVector aVUV = B3DVector(0.0,1.0,0.0)); 96 97 // addition, subtraction 98 B3DHomMatrix& operator+=(const B3DHomMatrix& rMat); 99 B3DHomMatrix& operator-=(const B3DHomMatrix& rMat); 100 101 // comparison 102 bool operator==(const B3DHomMatrix& rMat) const; 103 bool operator!=(const B3DHomMatrix& rMat) const; 104 105 // multiplication, division by constant value 106 B3DHomMatrix& operator*=(double fValue); 107 B3DHomMatrix& operator/=(double fValue); 108 109 // matrix multiplication (from the left) 110 B3DHomMatrix& operator*=(const B3DHomMatrix& rMat); 111 112 // assignment operator 113 B3DHomMatrix& operator=(const B3DHomMatrix& rMat); 114 B3DHomMatrix& operator=(B3DHomMatrix&& rMat); 115 116 // decomposition 117 void decompose(B3DTuple& rScale, B3DTuple& rTranslate, B3DTuple& rRotate, B3DTuple& rShear) const; 118 }; 119 operator *(const B3DHomMatrix & rMatA,const B3DHomMatrix & rMatB)120 inline B3DHomMatrix operator*(const B3DHomMatrix& rMatA, const B3DHomMatrix& rMatB) 121 { 122 B3DHomMatrix aMul(rMatB); 123 aMul *= rMatA; 124 return aMul; 125 } 126 } // end of namespace basegfx 127 128 #endif // INCLUDED_BASEGFX_MATRIX_B3DHOMMATRIX_HXX 129 130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 131