Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
grafika-hazi-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Rafael László
grafika-hazi-1
Commits
9912023a
Commit
9912023a
authored
Apr 4, 2020
by
Rafael László
Browse files
Options
Downloads
Patches
Plain Diff
angles and distances but not good
parent
a6125173
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
hazi1.cpp
+58
-16
58 additions, 16 deletions
hazi1.cpp
with
58 additions
and
16 deletions
hazi1.cpp
+
58
−
16
View file @
9912023a
...
...
@@ -293,6 +293,18 @@ vec2 getInverse(vec2 p){
return
p
/
(
length
(
p
)
*
length
(
p
));
}
float
getSiriusDistance
(
vec2
a
,
vec2
d
)
{
float
x
=
a
.
x
;
float
y
=
a
.
y
;
float
dx
=
d
.
x
-
a
.
x
;
float
dy
=
d
.
y
-
a
.
y
;
return
sqrt
(
dx
*
dx
+
dy
*
dy
)
/
(
1
-
x
*
x
-
y
*
y
);
}
inline
bool
equal
(
const
vec2
&
a
,
const
vec2
&
b
)
{
return
a
.
x
<
b
.
x
+
0.0001
&&
a
.
x
>
b
.
x
-
0.0001
&&
a
.
y
<
b
.
y
+
0.0001
&&
a
.
y
>
b
.
y
-
0.0001
;
}
class
SiriusTriangle
{
vec2
a
,
b
,
c
;
...
...
@@ -307,6 +319,12 @@ class SiriusTriangle{
return
degree
;
}
float
normalizeAngle
(
float
angle
)
{
if
(
angle
>
0
)
return
angle
;
return
2.0f
*
M_PI
+
angle
;
}
std
::
vector
<
vec2
>
getOneSide
(
vec2
p1
,
vec2
p2
){
// Inverse of p2
vec2
invp2
=
getInverse
(
p2
);
...
...
@@ -363,36 +381,62 @@ class SiriusTriangle{
return
generated
;
}
float
calculateAngle
(
std
::
vector
<
vec2
>
array
,
vec2
P
)
{
for
(
int
i
=
0
;
i
<
array
.
size
();
++
i
)
{
if
(
equal
(
array
[
i
],
P
))
{
vec2
p
=
array
[(
i
-
1
+
array
.
size
())
%
array
.
size
()]
-
P
;
vec2
n
=
array
[(
i
+
1
)
%
array
.
size
()]
-
P
;
return
abs
(
normalizeAngle
(
atan2
(
p
.
y
,
p
.
x
))
-
normalizeAngle
(
atan2
(
n
.
y
,
n
.
x
)))
/
M_PI
*
180.0f
;
}
}
return
0
;
}
public
:
float
sideAB
=
0
,
sideBC
=
0
,
sideCA
=
0
;
vec2
ccAB
,
ccBC
,
ccCA
;
float
angleAB
,
angleBC
,
angleCA
;
SiriusTriangle
(
vec2
p1
,
vec2
p2
,
vec2
p3
)
{
a
=
p1
;
b
=
p2
;
c
=
p3
;
ab
=
getOneSide
(
a
,
b
);
bc
=
getOneSide
(
b
,
c
);
ca
=
getOneSide
(
c
,
a
);
for
(
int
i
=
0
;
i
<
ab
.
size
()
-
1
;
++
i
)
{
sideAB
+=
getSiriusDistance
(
ab
[
i
],
ab
[
i
+
1
]);
}
for
(
int
i
=
0
;
i
<
bc
.
size
()
-
1
;
++
i
)
{
sideBC
+=
getSiriusDistance
(
bc
[
i
],
bc
[
i
+
1
]);
}
for
(
int
i
=
0
;
i
<
ca
.
size
()
-
1
;
++
i
)
{
sideCA
+=
getSiriusDistance
(
ca
[
i
],
ca
[
i
+
1
]);
}
std
::
vector
<
vec2
>
getAB
()
{
printf
(
"AB
\n
"
);
for
(
vec2
pp
:
ab
)
{
printf
(
"%f %f
\n
"
,
pp
.
x
,
pp
.
y
);
angleAB
=
calculateAngle
(
ab
,
p1
);
angleBC
=
calculateAngle
(
bc
,
p2
);
angleCA
=
calculateAngle
(
ca
,
p3
);
printf
(
"Alpha: %3.6f, Beta: %3.6f, Gamma: %3.6f, Sum: %3.6f
\n
"
,
angleAB
,
angleBC
,
angleCA
,
angleAB
+
angleBC
+
angleCA
);
printf
(
"AB: %3.6f, BC: %3.6f, CA: %3.6f
\n
"
,
sideAB
,
sideBC
,
sideCA
);
}
std
::
vector
<
vec2
>
getAB
()
{
return
ab
;
}
std
::
vector
<
vec2
>
getCA
()
{
printf
(
"ca
\n
"
);
for
(
vec2
pp
:
ca
)
{
printf
(
"%f %f
\n
"
,
pp
.
x
,
pp
.
y
);
}
return
ca
;
}
std
::
vector
<
vec2
>
getBC
()
{
printf
(
"BC
\n
"
);
for
(
vec2
pp
:
bc
)
{
printf
(
"%f %f
\n
"
,
pp
.
x
,
pp
.
y
);
}
return
bc
;
}
...
...
@@ -477,6 +521,8 @@ std::vector<FilledTriangle> getEars(std::vector<vec2> points){
return
tr
;
}
std
::
vector
<
FilledTriangle
>
triangles
;
std
::
vector
<
FilledTriangle
>
ears
;
BaseCircle
circle
;
...
...
@@ -553,14 +599,10 @@ void onMouse(int button, int state, int pX, int pY) { // pX, pY are the pixel co
if
(
button
==
GLUT_LEFT_BUTTON
&&
state
==
GLUT_DOWN
)
{
userPoints
.
emplace_back
(
cX
,
cY
);
// redpts.addPoint({cX, cY});
if
(
userPoints
.
size
()
==
3
)
{
SiriusTriangle
st
(
userPoints
[
0
],
userPoints
[
1
],
userPoints
[
2
]);
siriustriangles
.
emplace_back
(
st
);
// linestrip.emplace_back(st.getAB());
// linestrip.emplace_back(st.getBC());
// linestrip.emplace_back(st.getCA());
std
::
vector
<
vec2
>
siriusPoints
=
st
.
getPoints
();
linestrip
.
emplace_back
(
siriusPoints
);
siriusPoints
.
pop_back
();
// remove extra point
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment