Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Leander Schulten
Lichtsteuerung
Commits
6db147a3
Commit
6db147a3
authored
Sep 18, 2019
by
Leander Schulten
Browse files
MapView: remove random code added in commit
04e89581
parent
1fedb698
Pipeline
#184471
passed with stage
in 2 minutes and 21 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/gui/mapview.h
View file @
6db147a3
...
@@ -3,116 +3,10 @@
...
@@ -3,116 +3,10 @@
#include
"polygon.h"
#include
"polygon.h"
#include
"gridbackground.h"
#include
"gridbackground.h"
#include
<iostream>
#include
"scanner.h"
#include
"modules/modulemanager.h"
#include
"modules/modulemanager.h"
namespace
GUI
{
namespace
GUI
{
class
vector
{
public:
float
x
,
y
,
z
;
vector
(
float
x
,
float
y
,
float
z
)
:
x
(
x
),
y
(
y
),
z
(
z
){}
vector
()
:
x
(
0
),
y
(
0
),
z
(
0
){}
vector
&
normalize
(){
auto
sum
=
length
();
x
/=
sum
;
y
/=
sum
;
z
/=
sum
;
return
*
this
;
}
float
length
(){
return
std
::
sqrt
(
std
::
pow
(
x
,
2.
f
)
+
std
::
pow
(
y
,
2.
f
)
+
std
::
pow
(
z
,
2.
f
));
}
vector
&
operator
-=
(
const
vector
&
other
){
x
-=
other
.
x
;
y
-=
other
.
y
;
z
-=
other
.
z
;
return
*
this
;
}
operator
QString
()
const
{
return
QString
(
"vector("
)
+
QString
::
number
(
x
)
+
','
+
QString
::
number
(
y
)
+
','
+
QString
::
number
(
z
)
+
")"
;
}
};
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
o
,
const
vector
&
v
){
o
<<
"vector("
<<
v
.
x
<<
','
<<
v
.
y
<<
','
<<
v
.
z
<<
")"
;
return
o
;
}
static
inline
vector
scannerPosition
;
inline
vector
scannerRay
(
float
angleInRadians
){
return
vector
(
0
,
std
::
cos
(
angleInRadians
),
std
::
sin
(
angleInRadians
));
}
inline
vector
getVectorFromScannerToMouse
(
float
x
,
float
y
){
vector
vec
(
x
,
y
,
0
);
vec
-=
scannerPosition
;
vec
.
normalize
();
return
vec
;
}
inline
float
toDegrees
(
float
radians
){
return
(
radians
*
180.
f
)
/
static_cast
<
float
>
(
M_PI
);
}
inline
float
toRadians
(
float
degree
){
return
degree
*
static_cast
<
float
>
(
M_PI
)
/
180.
f
;
}
inline
vector
reflectVector
(
vector
incomingVec
,
float
beta
,
float
alpha
){
beta
=
toRadians
(
beta
);
alpha
=
toRadians
(
alpha
);
incomingVec
.
normalize
();
float
x
=
2.
f
*
std
::
sin
(
beta
)
*
std
::
sin
(
beta
);
float
y
=
2.
f
*
std
::
sin
(
beta
)
*
-
std
::
sin
(
alpha
)
*
std
::
cos
(
beta
);
float
z
=
2.
f
*
std
::
sin
(
beta
)
*
std
::
cos
(
alpha
)
*
std
::
cos
(
beta
);
incomingVec
-=
vector
(
x
,
y
,
z
);
qDebug
()
<<
"normal : "
<<
vector
(
std
::
sin
(
beta
),
-
std
::
sin
(
alpha
)
*
std
::
cos
(
beta
),
std
::
cos
(
alpha
)
*
std
::
cos
(
beta
));
return
incomingVec
;
}
inline
void
computeAnglesDebug
(
vector
position
){
auto
vecToScanner
=
vector
(
1
,
0
,
0
);
auto
vecFromScanner
=
position
.
normalize
();
qDebug
()
<<
"computeAngles : "
;
qDebug
()
<<
vecToScanner
;
qDebug
()
<<
vecFromScanner
;
qDebug
()
<<
(
vecFromScanner
.
x
-
1
)
/-
2.
f
;
qDebug
()
<<
-
std
::
sqrt
((
vecFromScanner
.
x
-
1
)
/-
2.
f
);
auto
beta
=
std
::
asin
(
-
std
::
sqrt
((
vecFromScanner
.
x
-
1
)
/-
2.
f
));
qDebug
()
<<
beta
;
qDebug
()
<<
toDegrees
(
beta
);
qDebug
()
<<
"v : "
<<
vector
(
std
::
sin
(
beta
),
0
,
std
::
cos
(
beta
));;
auto
b
=
std
::
cos
(
beta
)
*
std
::
sin
(
beta
);
auto
alpha1
=
std
::
asin
(
vecFromScanner
.
y
/
(
2.
f
*
b
));
qDebug
()
<<
toDegrees
(
alpha1
);
//auto alpha2 = std::acos(vecFromScanner.z / (-2.f * b));
//qDebug() << toDegrees(alpha2);
}
inline
void
computeAngles
(
vector
position
){
auto
vecToScanner
=
vector
(
1
,
0
,
0
);
auto
vecFromScanner
=
position
.
normalize
();
auto
beta
=
std
::
asin
(
-
std
::
sqrt
((
vecFromScanner
.
x
-
1
)
/-
2.
f
));
auto
b
=
std
::
cos
(
beta
)
*
std
::
sin
(
beta
);
auto
alpha
=
std
::
asin
(
vecFromScanner
.
y
/
(
2.
f
*
b
));
}
inline
void
test
(){
Scanner
scanner
(
QVector3D
(
20
,
200
,
200
),
90
,
30
);
auto
angles
=
scanner
.
computeAngleForStepMotorsForPositionOnMap
(
200
,
350
);
qDebug
()
<<
"alpha : "
<<
angles
.
first
<<
" betha : "
<<
angles
.
second
;
qDebug
()
<<
scanner
.
getTransformationMatrix
()
*
QVector3D
(
40
,
220
,
0
);
scannerPosition
=
{
20
,
200
,
200
};
//computeAngles(vector(0,0,1));
//qDebug() << reflectVector(vector(1,0,0),-10,0);
computeAngles
(
reflectVector
(
vector
(
1
,
0
,
0
),
-
10
,
-
45
));
computeAngles
(
vector
(
1
,
1
,
1
));
}
class
MapView
:
public
GridBackground
class
MapView
:
public
GridBackground
{
{
Q_OBJECT
Q_OBJECT
...
...
Write
Preview
Supports
Markdown
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