-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoordinates.cpp
83 lines (77 loc) · 1.86 KB
/
coordinates.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#include "coordinates.h"
#include <math.h>
#include <iostream>
using namespace std;
coordinates::~coordinates()
{
}
coordinates::coordinates(double fX, double fY, double startX, double startY)
{
coordinates::endX = fX;
coordinates::endY = fY;
coordinates::startX = startX;
coordinates::startY = startY;
}
double coordinates::multiplicationY(double param)
{
double t = (double)(endY*2) * param;
return t;
}
double coordinates::multiplicationX(double param)
{
double t = (double)(endX*2) * param;
return t;
}
double coordinates::convertNormalParaworldX(double coordX)
{
return round(multiplicationX(coordX) - endX);
}
double coordinates::convertDisplayParaNormalX(int x)
{
double t = (double) x / widthWindow;
return t ;
}
double coordinates::display2worldX(int x)
{
double normal = convertDisplayParaNormalX(x);
double world = convertNormalParaworldX(normal);
return world;
}
double coordinates::convertNormalParaworldY(double coordY)
{
return round(multiplicationY(coordY) - endY);
}
double coordinates::convertDisplayParaNormalY(int y)
{
double t = (double) y / heightWindow;
return t ;
}
double coordinates::display2worldY(int y)
{
double normal = convertDisplayParaNormalY(y);
int world = convertNormalParaworldY(normal);
return world;
}
void coordinates::setSizeWindow(int w, int h)
{
coordinates::heightWindow = h;
coordinates::widthWindow = w;
}
int coordinates::worldParaMatrixLine(double worldLine)
{
double l = (double) ((worldLine-startY) / (endY - startY));
return round(l * columns);
}
int coordinates::worldParaMatrixcolumn(double worldcolumn)
{
double c = (double) ((worldcolumn-startY) / (endY - startY));
return round(c * lines);
}
void coordinates::setlines(int l)
{
coordinates::lines = l;
}
void coordinates::setcolumns(int c)
{
coordinates::columns = c;
}