Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5f6b6df7
Commit
5f6b6df7
authored
Aug 08, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
befor changeing circular survey
parent
6ac2e382
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
109 additions
and
48 deletions
+109
-48
Circle.cc
src/Wima/Circle.cc
+51
-16
Circle.h
src/Wima/Circle.h
+2
-0
CircularSurveyComplexItem.cc
src/Wima/CircularSurveyComplexItem.cc
+39
-25
WimaPlaner.cc
src/Wima/WimaPlaner.cc
+17
-7
No files found.
src/Wima/Circle.cc
View file @
5f6b6df7
...
...
@@ -115,36 +115,71 @@ QList<QPointF> Circle::approximateSektor(int numberOfCorners, double alpha1, dou
QList
<
QPointF
>
Circle
::
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
{
using
namespace
PlanimetryCalculus
;
// truncate alpha1 to [0, 2*pi], fmod() does not work in this case
alpha1
=
truncateAngle
(
alpha1
);
alpha2
=
truncateAngle
(
alpha2
);
double
deltaAlpha
=
truncateAngle
(
alpha2
-
alpha1
);
angleDiscretisation
=
truncateAngle
(
angleDiscretisation
)
*
signum
(
angleDiscretisation
);
// check if input is valid
if
(
qFuzzyCompare
(
alpha1
,
alpha2
)
)
return
QList
<
QPointF
>
();
alpha1
=
truncateAngle
(
alpha1
);
alpha2
=
truncateAngle
(
alpha2
);
double
deltaAlpha
=
fabs
(
alpha1
-
alpha2
);
if
(
signum
(
angleDiscretisation
*
(
alpha1
-
alpha2
))
==
1
)
{
deltaAlpha
=
2
*
M_PI
-
deltaAlpha
;
}
if
(
fabs
(
angleDiscretisation
)
>
deltaAlpha
||
qFuzzyIsNull
(
angleDiscretisation
))
// check if input is valid
if
(
fabs
(
angleDiscretisation
)
>
fabs
(
deltaAlpha
)
||
qFuzzyIsNull
(
angleDiscretisation
))
return
QList
<
QPointF
>
();
QList
<
QPointF
>
sector
;
QPointF
vertex0
(
_circleRadius
,
0
);
// initial vertex
double
currentAngle
=
alpha1
;
// rotate the vertex numberOfCorners-1 times add the origin and append to the polygon.
// how many nodes?
int
j
=
floor
(
fabs
(
deltaAlpha
/
angleDiscretisation
));
// rotate the vertex j+1 times add the origin and append to the sector.
do
{
QPointF
currentVertex
=
rotateReturn
(
vertex0
,
currentAngle
);
sector
.
append
(
currentVertex
+
_circleOrigin
);
currentAngle
=
PlanimetryCalculus
::
truncateAngle
(
currentAngle
+
angleDiscretisation
);
}
while
(
currentAngle
<
alpha2
);
sector
.
append
(
toCoordinate
(
currentAngle
));
currentAngle
=
truncateAngle
(
currentAngle
+
angleDiscretisation
);
}
while
(
j
--
);
// append last point if necessarry
QPointF
currentVertex
=
rotateReturn
(
vertex0
,
alpha2
)
+
_circleOrigin
;
if
(
!
qFuzzyIsNull
(
PlanimetryCalculus
::
distance
(
sector
.
first
(),
currentV
ertex
))
&&
!
qFuzzyIsNull
(
PlanimetryCalculus
::
distance
(
sector
.
last
(),
currentV
ertex
))
){
sector
.
append
(
currentV
ertex
);
QPointF
vertex
=
toCoordinate
(
alpha2
)
;
if
(
!
qFuzzyIsNull
(
PlanimetryCalculus
::
distance
(
sector
.
first
(),
v
ertex
))
&&
!
qFuzzyIsNull
(
PlanimetryCalculus
::
distance
(
sector
.
last
(),
v
ertex
))
){
sector
.
append
(
v
ertex
);
}
return
sector
;
}
/*!
* \fn void Circle::toCoordinate(QPointF &coordinate, double alpha) const
* Calculates the coordinates of a point on the circle with angle \a alpha.
* Stores the result in \a coordiante.
*
* \sa QPointF
*/
void
Circle
::
toCoordinate
(
QPointF
&
coordinate
,
double
alpha
)
const
{
using
namespace
PlanimetryCalculus
;
coordinate
=
QPointF
(
_circleRadius
,
0
);
rotateReference
(
coordinate
,
alpha
);
coordinate
+=
_circleOrigin
;
}
/*!
* \overload QPointF Circle::toCoordinate(double alpha) const
* Returns the coordinates of a point on the circle with angle \a alpha.
*
* \sa QPointF
*/
QPointF
Circle
::
toCoordinate
(
double
alpha
)
const
{
QPointF
coordinate
;
toCoordinate
(
coordinate
,
alpha
);
return
coordinate
;
}
bool
Circle
::
isNull
()
const
{
return
_circleRadius
<=
0
?
true
:
false
;
...
...
src/Wima/Circle.h
View file @
5f6b6df7
...
...
@@ -31,6 +31,8 @@ public:
QList
<
QPointF
>
approximate
(
double
angleDiscretisation
)
const
;
QList
<
QPointF
>
approximateSektor
(
int
numberOfCorners
,
double
alpha1
,
double
alpha2
)
const
;
QList
<
QPointF
>
approximateSektor
(
double
angleDiscretisation
,
double
alpha1
,
double
alpha2
)
const
;
void
toCoordinate
(
QPointF
&
toCoordinate
,
double
alpha
)
const
;
QPointF
toCoordinate
(
double
alpha
)
const
;
bool
isNull
()
const
;
signals:
...
...
src/Wima/CircularSurveyComplexItem.cc
View file @
5f6b6df7
...
...
@@ -102,9 +102,9 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
}
}
qWarning
(
"r_min, r_max:"
);
qWarning
()
<<
r_min
;
qWarning
()
<<
r_max
;
//
qWarning("r_min, r_max:");
//
qWarning() << r_min;
//
qWarning() << r_max;
QList
<
QPolygonF
>
convexPolygons
;
decomposeToConvex
(
surveyPolygon
,
convexPolygons
);
...
...
@@ -116,44 +116,58 @@ void CircularSurveyComplexItem::_rebuildTransectsPhase1()
QList
<
QList
<
QPointF
>>
currPolyPath
;
bool
currentPolyPathUpdated
=
false
;
int
direction
=
1
;
while
(
r
<
r_max
)
{
Circle
circle
(
r
,
origin
);
QList
<
QPointFList
>
intersectPoints
;
QList
<
IntersectType
>
typeList
;
if
(
intersects
(
circle
,
polygon
,
intersectPoints
,
typeList
))
{
QList
<
QPair
<
int
,
int
>>
neighbourList
;
if
(
intersects
(
circle
,
polygon
,
intersectPoints
,
neighbourList
,
typeList
))
{
if
(
intersectPoints
.
size
()
>=
1
)
{
// continue here
QPointF
p1
=
intersectPoints
.
first
()[
0
];
QPointF
p2
=
intersectPoints
.
first
()[
1
];
double
beta1
=
angle
(
p1
);
double
beta2
=
angle
(
p2
);
double
alpha1
=
fmin
(
beta1
,
beta2
);
double
alpha2
=
fmax
(
beta1
,
beta2
);
QList
<
QPointF
>
sector
=
circle
.
approximateSektor
(
direction
*
dalpha
,
alpha1
,
alpha2
);
QList
<
QPointF
>
sectorPath
;
for
(
const
QPointF
&
p
:
sector
)
{
if
(
polygon
.
containsPoint
(
p
,
Qt
::
FillRule
::
OddEvenFill
))
sectorPath
.
append
(
p
);
}
if
(
sectorPath
.
size
()
>
0
)
{
if
(
direction
==
-
1
){
direction
=
1
;
}
else
direction
=
-
1
;
for
(
int
i
=
0
;
i
<
intersectPoints
.
size
();
i
++
)
{
QList
<
QPointF
>
intersects
=
intersectPoints
[
i
];
QPointF
p1
=
polygon
[
neighbourList
[
i
].
first
];
QPointF
p2
=
polygon
[
neighbourList
[
i
].
second
];
QLineF
intersetLine
(
p1
,
p2
);
double
lineAngle
=
truncateAngle
(
angle
(
intersetLine
));
double
alpha1
=
0
;
bool
skip
=
true
;
QPointF
vertex
;
for
(
QPointF
ipt
:
intersects
)
{
double
circleTangentAngle
=
truncateAngle
(
angle
(
ipt
)
+
M_PI_2
);
if
(
lineAngle
>
circleTangentAngle
&&
lineAngle
<
circleTangentAngle
+
M_PI
)
{
alpha1
=
truncateAngle
(
circleTangentAngle
-
M_PI_2
);
vertex
=
ipt
;
skip
=
false
;
}
}
QList
<
QPointF
>
sectorPath
;
// walk clockwisely along the circle, and break when leaving the polygon
if
(
!
skip
)
{
double
alpha
=
alpha1
;
do
{
sectorPath
.
append
(
vertex
);
alpha
+=
dalpha
;
circle
.
toCoordinate
(
vertex
,
alpha
);
}
while
(
polygon
.
containsPoint
(
vertex
,
Qt
::
FillRule
::
OddEvenFill
));
}
// use shortestPath() here if necessary, could be a problem if dr >>
currPolyPath
.
append
(
sectorPath
);
currentPolyPathUpdated
=
true
;
}
}
}
r
+=
dr
;
}
if
(
currentPolyPathUpdated
)
{
if
(
fullPath
.
size
()
>
1
)
{
QPointF
start
=
fullPath
.
last
().
last
();
...
...
src/Wima/WimaPlaner.cc
View file @
5f6b6df7
...
...
@@ -532,13 +532,23 @@ bool WimaPlaner::recalcJoinedArea(QString &errorString)
// join service area, op area and corridor
// remove if debugging finished
WimaServiceArea
*
test
=
new
WimaServiceArea
(
this
);
Circle
circle
(
25
,
this
);
using
namespace
GeoUtilities
;
test
->
setPath
(
toGeo
(
circle
.
approximateSektor
(
10
,
-
1
,
1
),
_joinedArea
.
center
()));
_visualItems
.
append
(
test
);
// // remove if debugging finished
// WimaServiceArea *test = new WimaServiceArea(this);
// WimaServiceArea *test1 = new WimaServiceArea(this);
// WimaServiceArea *test2 = new WimaServiceArea(this);
// WimaServiceArea *test3 = new WimaServiceArea(this);
// Circle circle(25, this);
// using namespace GeoUtilities;
// test->setPath(toGeo(circle.approximateSektor(0.5, 1, 3), _joinedArea.center()));
// _visualItems.append(test);
// test1->setPath(toGeo(circle.approximateSektor(0.5, 1, -1), _joinedArea.center()));
// _visualItems.append(test1);
// test2->setPath(toGeo(circle.approximateSektor(0.5,-1, 3), _joinedArea.center()));
// _visualItems.append(test2);
// test3->setPath(toGeo(circle.approximateSektor(0.5, -1, -3), _joinedArea.center()));
// _visualItems.append(test3);
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment