Tissue Forge C++ 0.2.1
Interactive, particle-based physics, chemistry and biology modeling and simulation environment
Loading...
Searching...
No Matches
tfMatrix3.h
1/*******************************************************************************
2 * This file is part of Tissue Forge.
3 * Copyright (c) 2022-2024 T.J. Sego
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19
20#ifndef _SOURCE_TYPES_TFMATRIX3_H_
21#define _SOURCE_TYPES_TFMATRIX3_H_
22
23#include "tfMatrix.h"
24#include "tfVector3.h"
25
26#include <Magnum/Math/Matrix3.h>
27
28
29namespace TissueForge::types {
30
31
32 template<class T> using Matrix3Base = Magnum::Math::Matrix3<T>;
33
34 template<class T>
35 class TMatrix3 : public Matrix3Base<T> {
36 public:
38 static TMatrix3<T> rotation(T angle) { return (TMatrix3<T>)Matrix3Base<T>::rotation(Magnum::Math::Rad<T>(angle)); }
39
41 constexpr static TMatrix3<T> shearingX(T amount) { return (TMatrix3<T>)Matrix3Base<T>::shearingX(amount); }
42
44 constexpr static TMatrix3<T> shearingY(T amount) { return (TMatrix3<T>)Matrix3Base<T>::shearingY(amount); }
45
46 constexpr TMatrix3() noexcept: Matrix3Base<T>() {}
47
48 constexpr TMatrix3(const TVector3<T>& first, const TVector3<T>& second, const TVector3<T>& third) noexcept:
49 Matrix3Base<T>(Magnum::Math::Vector3<T>(first), Magnum::Math::Vector3<T>(second), Magnum::Math::Vector3<T>(third)) {}
50
51 constexpr explicit TMatrix3(T value) noexcept: Matrix3Base<T>(value) {}
52
53 template<class U> constexpr explicit TMatrix3(const TMatrix3<U>& other) noexcept: Matrix3Base<T>((Matrix3Base<U>)other) {}
54
55 template<std::size_t otherSize> constexpr explicit TMatrix3(const TMatrixS<otherSize, T>& other) noexcept: Matrix3Base<T>{(TMatrixS<otherSize, T>)other} {}
56
58 bool isRigidTransformation() const { return Matrix3Base<T>::isRigidTransformation(); }
59
61 TMatrix3<T> invertedRigid() const { return (TMatrix3<T>)Matrix3Base<T>::invertedRigid(); }
62
63 TMatrix3(const std::vector<T> &v1, const std::vector<T> &v2, const std::vector<T> &v3) :
64 TMatrix3<T>(TVector3<T>(v1), TVector3<T>(v2), TVector3<T>(v3)) {}
65
66 MAGNUM_BASE_MATRIX_CAST_METHODS(3, TMatrix3, Matrix3Base)
67
68 REVISED_MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(3, TMatrix3, Matrix3Base, TVector3)
69
70 #ifdef SWIGPYTHON
71 SWIGPYTHON_MAGNUM_MATRIX_SUBCLASS_IMPLEMENTATION(3, TMatrix3, TVector3)
72 #endif
73
74 };
75
76}
77
78TF_MATRIX_IMPL_OSTREAM(TissueForge::types::TMatrix3)
79
80#endif // _SOURCE_TYPES_TFMATRIX3_H_
Definition tfMatrix3.h:35
static constexpr TMatrix3< T > shearingX(T amount)
Definition tfMatrix3.h:41
bool isRigidTransformation() const
Definition tfMatrix3.h:58
static constexpr TMatrix3< T > shearingY(T amount)
Definition tfMatrix3.h:44
static TMatrix3< T > rotation(T angle)
Definition tfMatrix3.h:38
TMatrix3< T > invertedRigid() const
Definition tfMatrix3.h:61
Definition tfVector3.h:35
Native Tissue Forge type definitions.
Definition tfMatrix.h:33