File indexing completed on 2025-01-19 03:51:13
0001 /* ============================================================ 0002 * 0003 * This file is a part of digiKam project 0004 * https://www.digikam.org 0005 * 0006 * Date : 2005-02-17 0007 * Description : a matrix implementation for image 0008 * perspective adjustment. 0009 * 0010 * SPDX-FileCopyrightText: 2005-2024 by Gilles Caulier <caulier dot gilles at gmail dot com> 0011 * SPDX-FileCopyrightText: 2006-2012 by Marcel Wiesweg <marcel dot wiesweg at gmx dot de> 0012 * 0013 * SPDX-License-Identifier: GPL-2.0-or-later 0014 * 0015 * ============================================================ */ 0016 0017 #ifndef DIGIKAM_EDITOR_PERSPECTIVE_MATRIX_H 0018 #define DIGIKAM_EDITOR_PERSPECTIVE_MATRIX_H 0019 0020 namespace DigikamEditorPerspectiveToolPlugin 0021 { 0022 0023 class PerspectiveMatrix 0024 { 0025 public: 0026 0027 /** 0028 * PerspectiveMatrix: 0029 * 0030 * Initializes matrix to the identity matrix. 0031 */ 0032 explicit PerspectiveMatrix(); 0033 0034 /** 0035 * translate: 0036 * @param x Translation in X direction. 0037 * @param y Translation in Y direction. 0038 * 0039 * Translates the matrix by x and y. 0040 */ 0041 void translate(double x, double y); 0042 0043 /** 0044 * scale: 0045 * @param x X scale factor. 0046 * @param y Y scale factor. 0047 * 0048 * Scales the matrix by x and y 0049 */ 0050 void scale(double x, double y); 0051 0052 /** 0053 * invert: 0054 * 0055 * Inverts this matrix. 0056 */ 0057 void invert(); 0058 0059 /** 0060 * multiply: 0061 * @param matrix1 The other input matrix. 0062 * 0063 * Multiplies this matrix with another matrix 0064 */ 0065 void multiply(const PerspectiveMatrix& matrix1); 0066 0067 /** 0068 * transformPoint: 0069 * @param x The source X coordinate. 0070 * @param y The source Y coordinate. 0071 * @param newx The transformed X coordinate. 0072 * @param newy The transformed Y coordinate. 0073 * 0074 * Transforms a point in 2D as specified by the transformation matrix. 0075 */ 0076 void transformPoint(double x, double y, double* newx, double* newy) const; 0077 0078 /** 0079 * determinant: 0080 * 0081 * Calculates the determinant of this matrix. 0082 * 0083 * Returns: The determinant. 0084 */ 0085 double determinant() const; 0086 0087 public: 0088 0089 /** 0090 * coeff: 0091 * 0092 * The 3x3 matrix data 0093 */ 0094 double coeff[3][3]; 0095 }; 0096 0097 } // namespace DigikamEditorPerspectiveToolPlugin 0098 0099 #endif // DIGIKAM_EDITOR_PERSPECTIVE_MATRIX_H