/*************************************************************************** * Copyright (C) gempa GmbH * * All rights reserved. * * Contact: gempa GmbH (seiscomp-dev@gempa.de) * * * * GNU Affero General Public License Usage * * This file may be used under the terms of the GNU Affero * * Public License version 3.0 as published by the Free Software Foundation * * and appearing in the file LICENSE included in the packaging of this * * file. Please review the following information to ensure the GNU Affero * * Public License version 3.0 requirements will be met: * * https://www.gnu.org/licenses/agpl-3.0.html. * * * * Other Usage * * Alternatively, this file may be used in accordance with the terms and * * conditions contained in a signed written agreement between you and * * gempa GmbH. * ***************************************************************************/ #ifndef SEISCOMP_MATH_MATRIX3_H #define SEISCOMP_MATH_MATRIX3_H #include #include namespace Seiscomp { namespace Math { template struct Matrix3 { Matrix3() {} Matrix3(const Matrix3 &other) { memcpy(d, other.d, sizeof(d)); } Matrix3 &identity(); Matrix3 &setRow(int row, const Vector3 &v); Matrix3 &setColumn(int col, const Vector3 &v); //! Returns a copy of the r-th row Vector3 row(int r) const; //! Returns a copy of the c-th column Vector3 column(int c) const; Matrix3 &loadRotateX(T theta); Matrix3 &loadRotateY(T theta); Matrix3 &loadRotateZ(T theta); Matrix3 &mult(const Matrix3 &a, const Matrix3 &b); Vector3 &transform(Vector3 &dst, const Vector3 &v) const; Vector3 &invTransform(Vector3 &dst, const Vector3 &v) const; operator T *() { return (T*)this; } operator const T *() const { return (const T*)this; } Vector3 operator*(const Vector3 &v) const; // Coefficients union { T d[3][3]; struct { T _11, _12, _13; T _21, _22, _23; T _31, _32, _33; } c; }; }; typedef Matrix3 Matrix3f; typedef Matrix3 Matrix3d; #include } // namespace Math } // namespace Seiscomp #endif