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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130 | /**
* @file Tools/ImageProcessing/BresenhamLineScan.cpp
*
* Utility class which performs the Bresenham algorithm for line scanning
*
* @author <a href="mailto:timlaue@tzi.de">Tim Laue</a>
* @author <a href="mailto:walter.nistico@uni-dortmund.de">Walter Nistico</a>
* @author <a href="mailto:oberlies@sim.tu-darmstadt.de">Tobias Oberlies</a> (revised constructors and commenting)
*/
#include "BresenhamLineScan.h"
#include "Tools/Math/Geometry.h"
using namespace naoth;
BresenhamLineScan::BresenhamLineScan()<--- Member variable 'BresenhamLineScan::numberOfPixels' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::pixelCount' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::alongX' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::delta' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::baseError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::resetError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::error' is not initialized in the constructor.
{
double dir = Math::pi_2;
setup(dir);
}
BresenhamLineScan::BresenhamLineScan(const Vector2i& start, const Vector2i& end)<--- Member variable 'BresenhamLineScan::numberOfPixels' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::pixelCount' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::alongX' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::delta' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::baseError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::resetError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::error' is not initialized in the constructor.
{
setup(start, end);
}
BresenhamLineScan::BresenhamLineScan(const Vector2d& direction)<--- Member variable 'BresenhamLineScan::numberOfPixels' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::pixelCount' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::alongX' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::delta' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::baseError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::resetError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::error' is not initialized in the constructor.
{
setup(direction);
}
BresenhamLineScan::BresenhamLineScan(const double& direction)<--- Member variable 'BresenhamLineScan::numberOfPixels' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::pixelCount' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::alongX' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::delta' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::baseError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::resetError' is not initialized in the constructor.<--- Member variable 'BresenhamLineScan::error' is not initialized in the constructor.
{
setup(direction);
}
BresenhamLineScan::BresenhamLineScan(const Vector2i& start, const Vector2d& direction, const CameraInfo& cameraInfo)
{
setup(start, direction, cameraInfo);
}
BresenhamLineScan::BresenhamLineScan(const Vector2i& start, const double& direction, const CameraInfo& cameraInfo)
{
setup(start, direction, cameraInfo);
}
BresenhamLineScan::BresenhamLineScan(const Math::Line& line, const CameraInfo& cameraInfo)
{
setup(line, cameraInfo);
}
void BresenhamLineScan::setup(const Vector2i& diff)
{
int dx = diff.x;
int dy = diff.y;
int incX = ((dx>0) ? 1:-1);
int incY = ((dy>0) ? 1:-1);
int absDx(abs(dx));
int absDy(abs(dy));
alongX = (absDy < absDx);
if(alongX)
{
baseError = -absDx;
delta = 2*absDy;
standardOffset.x = incX;
standardOffset.y = 0;
correctionOffset.x = 0;
correctionOffset.y = incY;
numberOfPixels = absDx;
}
else
{
baseError = -absDy;
delta = 2*absDx;
standardOffset.x = 0;
standardOffset.y = incY;
correctionOffset.x = incX;
correctionOffset.y = 0;
numberOfPixels = absDy;
}
resetError = 2*baseError;
error = baseError; //added, for lines != 45 degrees
pixelCount = 0;
}//end setup
void BresenhamLineScan::setup(const Vector2i& start, const Vector2i& end)
{
setup(end-start);
}
void BresenhamLineScan::setup(const double& direction)
{
setup(Vector2i(static_cast<int>(cos(direction)*1024.0), static_cast<int>(sin(direction)*1024.0)));
}
void BresenhamLineScan::setup(const Vector2d& direction)
{
setup(Vector2i(static_cast<int>(direction.x*1024.0), static_cast<int>(direction.y*1024.0)));
}
void BresenhamLineScan::setup(const Vector2i& start, const double& direction, const CameraInfo& cameraInfo)
{
// Create a line through the point start with the given direction
Math::Line line(Pose2D(direction, start));
setup(line, cameraInfo);
}
void BresenhamLineScan::setup(const Vector2i& start, const Vector2d& direction, const CameraInfo& cameraInfo)
{
// Create a line through the point start with the given direction
Math::Line line(start, direction);
setup(line, cameraInfo);
}
void BresenhamLineScan::setup(const Math::Line& line, const CameraInfo& cameraInfo)
{
Vector2i pointOne;
Vector2i pointTwo;
const Vector2i frameUpperLeft(0,0);
const Vector2i frameLowerRight(cameraInfo.resolutionWidth-1, cameraInfo.resolutionHeight-1);
Geometry::getIntersectionPointsOfLineAndRectangle(frameUpperLeft, frameLowerRight, line, pointOne, pointTwo);
setup(pointTwo - line.getBase());
}//end setup
|