#include <trajectory.h>
Definition at line 14 of file trajectory.h.
◆ Trajectory()
| Trajectory::Trajectory |
( |
| ) |
|
◆ ~Trajectory()
| Trajectory::~Trajectory |
( |
| ) |
|
◆ addPoint()
| void Trajectory::addPoint |
( |
QPointF | pos | ) |
|
|
private |
◆ getDDATrajectory()
| QVector< QPointF > Trajectory::getDDATrajectory |
( |
QPointF | start, |
|
|
QPointF | end, |
|
|
double | space ) |
Definition at line 103 of file trajectory.cpp.
104{
105 Q_UNUSED(space);
107
108 int xd = (int)(end.x() - start.x());
109 int yd = (int)(end.y() - start.y());
110
111 int x = (int)start.x();
112 int y = (int)start.y();
113 float fx = start.x();
114 float fy = start.y();
115 float m = (float)yd / (float)xd;
116 int y2 = (int)end.y();
117 int x2 = (int)end.x();
118
119 if (fabs(m) > 1) {
120 int incr;
121 if (yd > 0) {
122 m = 1.0f / m;
123 incr = 1;
124 }
125 else {
126 m = -1.0f / m;
127 incr = -1;
128 }
129 while (y != y2) {
130 fx = fx + m;
132 x = (int)(fx + 0.5f);
134 }
135 } else {
136 int incr;
137 if (xd > 0) {
138 incr = 1;
139 }
140 else {
141 incr = -1;
142 m = -m;
143 }
144 while (x != x2) {
145 fy = fy + m;
147 y = (int)(fy + 0.5f);
149 }
150 }
151
153}
void addPoint(QPointF pos)
References addPoint(), m_path, and reset().
◆ getLinearTrajectory()
| const QVector< QPointF > & Trajectory::getLinearTrajectory |
( |
const QPointF & | start, |
|
|
const QPointF & | end, |
|
|
double | space ) |
Definition at line 44 of file trajectory.cpp.
45{
46 Q_UNUSED(space);
48
49
50 qreal xd = (end.x() - start.x());
51 qreal yd = (end.y() - start.y());
52
53 int x = (int)start.x();
54 int y = (int)start.y();
55 qreal fx = start.x();
56 qreal fy = start.y();
57 qreal m = yd / xd;
58
59 int y2 = (int)end.y();
60 int x2 = (int)end.x();
61
63
64 if (fabs(m) > 1) {
65
66 int incr;
67 if (yd > 0) {
68 m = 1.0f / m;
69 incr = 1;
70 } else {
71 m = -1.0f / m;
72 incr = -1;
73 }
74 while (y != y2) {
75 fx = fx + m;
76 fy = fy + incr;
78
80 }
81 } else {
82
83 int incr;
84 if (xd > 0) {
85 incr = 1;
86 } else {
87 incr = -1;
88 m = -m;
89 }
90 while (x != x2) {
91 fy = fy + m;
92 fx = fx + incr;
94
96 }
97 }
98
101}
References addPoint(), m_path, and reset().
◆ reset()
| void Trajectory::reset |
( |
| ) |
|
|
private |
◆ size()
| int Trajectory::size |
( |
| ) |
const |
|
inline |
◆ m_i
◆ m_path
| QVector<QPointF> Trajectory::m_path |
|
private |
◆ m_size
The documentation for this class was generated from the following files: