2 #include "oxygine-include.h" 13 typedef VectorT2<T> vector2;
14 typedef AffineTransformT<T> affineTransform;
15 typedef MatrixT<T> matrix;
18 AffineTransformT(T a_, T b_, T c_, T d_, T x_, T y_): a(a_), b(b_), c(c_), d(d_), x(x_), y(y_) {}
21 explicit AffineTransformT(
const matrix& m)
41 static affineTransform getIdentity()
48 void translate(
const vector2& v)
50 x += a * v.x + c * v.y;
51 y += b * v.x + d * v.y;
54 affineTransform translated(
const vector2& v)
const 56 affineTransform t = *
this;
61 void scale(
const vector2& v)
69 affineTransform scaled(
const vector2& v)
const 71 affineTransform t = *
this;
78 T sin_ = scalar::sin(v);
79 T cos_ = scalar::cos(v);
81 affineTransform rot(cos_, sin_, -sin_, cos_, 0, 0);
85 affineTransform rotated(T v)
const 87 affineTransform t = *
this;
94 affineTransform t = *
this;
96 T det = T(1) / (t.a * t.d - t.b * t.c);
102 x = det * (t.c * t.y - t.d * t.x);
103 y = det * (t.b * t.x - t.a * t.y);
106 affineTransform inverted()
const 108 affineTransform t = *
this;
113 operator matrix()
const 118 matrix toMatrix()
const 129 static affineTransform& multiply(affineTransform& out,
const affineTransform& t1,
const affineTransform& t2)
131 out.a = t1.a * t2.a + t1.b * t2.c;
132 out.b = t1.a * t2.b + t1.b * t2.d;
133 out.c = t1.c * t2.a + t1.d * t2.c;
134 out.d = t1.c * t2.b + t1.d * t2.d;
135 out.x = t1.x * t2.a + t1.y * t2.c + t2.x;
136 out.y = t1.x * t2.b + t1.y * t2.d + t2.y;
142 affineTransform operator * (
const affineTransform& t2)
const 145 multiply(r, *
this, t2);
149 vector2 transform(
const vector2& v)
const 152 a * v.x + c * v.y + x,
153 b * v.x + d * v.y + y);
161 typedef AffineTransformT<float> AffineTransform;
–oxgl-end–!
Definition: Actor.h:14