PeriDyno 1.0.0
Loading...
Searching...
No Matches
Transform2x2.inl
Go to the documentation of this file.
1#include <cmath>
2#include <limits>
3
4#include "Vector.h"
5
6namespace dyno
7{
8 template <typename T>
10 {
13 mRotation = SquareMatrix<T, 2>(1, 0, 0, 1);
14 }
15
16 template <typename T>
17 DYN_FUNC Transform<T, 2>::Transform(const Vector<T, 2>& t, const T& angle, const Vector<T, 2>& s)
18 {
19 mTranslation = t;
20 mScale = s;
21 mRotation = SquareMatrix<T, 2>(glm::cos(angle), -glm::sin(angle), glm::sin(angle), glm::cos(angle));
22 }
23
24 template <typename T>
25 DYN_FUNC Transform<T, 2>::Transform(const Vector<T, 2>& t, const SquareMatrix<T, 2>& m, const Vector<T, 2>& s /*= Vector<T, 2>(1)*/)
26 {
27 mTranslation = t;
28 mScale = s;
29 mRotation = m;
30 }
31
32 template <typename T>
34 {
35 mRotation = t.mRotation;
36 mTranslation = t.mTranslation;
37 mScale = t.mScale;
38 }
39
40 template <typename T>
42 {
43
44 }
45
46 template <typename T>
47 DYN_FUNC const Vector<T, 2> Transform<T, 2>::operator* (const Vector<T, 2> &vec) const
48 {
49 Vector<T, 2> scaled = Vector<T, 2>(vec.x*mScale.x, vec.y*mScale.y);
50 return mRotation * scaled + mTranslation;
51 }
52}
SquareMatrix< T, 2 > mRotation
Vector< T, 2 > mScale
Vector< T, 2 > mTranslation
#define T(t)
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25