-
Notifications
You must be signed in to change notification settings - Fork 0
/
linepoints.cpp
49 lines (36 loc) · 968 Bytes
/
linepoints.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
#include "linepoints.h"
using namespace PreProcessing;
using namespace std;
LinePoints::LinePoints()
{
}
Point LinePoints::pointOfLine(double i, PList points)
{
Scale scaler;
Point p = points.getPoint(0);
scaler.rectScale(points,i);
Point newPoint;
newPoint.x = points.getPoint(1).x + p.x - points.getPoint(0).x;
newPoint.y = points.getPoint(1).y + p.y - points.getPoint(0).y;
return newPoint;
}
PList LinePoints::getLinesPoints(PList points)
{
PList result;
for(int i = 1; i < points.getSize(); i++)
{
double rate;
if ( abs(points.getPoint(i-1).x - points.getPoint(i).x) > abs(points.getPoint(i-1).y - points.getPoint(i).y))
rate = abs(points.getPoint(i-1).x - points.getPoint(i).x);
else
rate = abs(points.getPoint(i-1).y - points.getPoint(i).y);
PList p;
p.pushPoint(points.getPoint(i-1));
p.pushPoint(points.getPoint(i));
for (int j = 0; j < rate; j++)
{
result.pushPoint(pointOfLine(j,p));
}
}
return result;
}