1
2#include "Projection.h"
3
4namespace msdfgen {
5
6Projection::Projection() : scale(1), translate(0) { }
7
8Projection::Projection(const Vector2 &scale, const Vector2 &translate) : scale(scale), translate(translate) { }
9
10Point2 Projection::project(const Point2 &coord) const {
11 return scale*(coord+translate);
12}
13
14Point2 Projection::unproject(const Point2 &coord) const {
15 return coord/scale-translate;
16}
17
18Vector2 Projection::projectVector(const Vector2 &vector) const {
19 return scale*vector;
20}
21
22Vector2 Projection::unprojectVector(const Vector2 &vector) const {
23 return vector/scale;
24}
25
26double Projection::projectX(double x) const {
27 return scale.x*(x+translate.x);
28}
29
30double Projection::projectY(double y) const {
31 return scale.y*(y+translate.y);
32}
33
34double Projection::unprojectX(double x) const {
35 return x/scale.x-translate.x;
36}
37
38double Projection::unprojectY(double y) const {
39 return y/scale.y-translate.y;
40}
41
42}
43