Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
grafika elso hf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Show more breadcrumbs
Börcsök Barnabás
grafika elso hf
Commits
655e0c11
Commit
655e0c11
authored
Apr 4, 2020
by
bobarna
Browse files
Options
Downloads
Patches
Plain Diff
asd
parent
4de7ef74
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
sirius.cpp
+23
-17
23 additions, 17 deletions
sirius.cpp
with
23 additions
and
17 deletions
sirius.cpp
+
23
−
17
View file @
655e0c11
...
@@ -229,17 +229,23 @@ public:
...
@@ -229,17 +229,23 @@ public:
vec2
currPotDiag1
=
*
getNextVertex
(
currVertex
);
vec2
currPotDiag1
=
*
getNextVertex
(
currVertex
);
vec2
currPotDiag2
=
*
getPreviousVertex
(
currVertex
);
vec2
currPotDiag2
=
*
getPreviousVertex
(
currVertex
);
//check if current potential diagonal intersects any edges
auto
intersectsOtherEdges
=
[
&
]()
->
bool
{
// skipping edges that share a vertex with it
for
(
auto
currEdgeStart
=
getPreviousVertex
(
getPreviousVertex
(
currVertex
));
for
(
auto
currEdgeStart
=
getPreviousVertex
(
getPreviousVertex
(
currVertex
));
currEdgeStart
!=
getNextVertex
(
getNextVertex
(
currVertex
));
currEdgeStart
=
getPreviousVertex
(
currEdgeStart
))
currEdgeStart
!=
getNextVertex
(
getNextVertex
(
currVertex
));
currEdgeStart
=
getPreviousVertex
(
currEdgeStart
))
if
(
intersectEachOther
(
vec2
(
currEdgeStart
->
x
,
currEdgeStart
->
y
),
if
(
intersectEachOther
(
vec2
(
currEdgeStart
->
x
,
currEdgeStart
->
y
),
vec2
(
getNextVertex
(
currEdgeStart
)
->
x
,
getNextVertex
(
currEdgeStart
)
->
y
),
vec2
(
getNextVertex
(
currEdgeStart
)
->
x
,
getNextVertex
(
currEdgeStart
)
->
y
),
currPotDiag1
,
currPotDiag2
))
{
currPotDiag1
,
currPotDiag2
))
{
currVertex
++
;
return
true
;
break
;
}
}
return
false
;
};
//check if current potential diagonal intersects any edges
// skipping edges that share a vertex with it
if
(
intersectsOtherEdges
())
{
currVertex
++
;
}
//check if current potential diagonal is fully outside the polygon
//check if current potential diagonal is fully outside the polygon
vec2
infinity
(
200
,
200
);
vec2
infinity
(
200
,
200
);
...
@@ -253,7 +259,7 @@ public:
...
@@ -253,7 +259,7 @@ public:
numberOfIntersections
++
;
numberOfIntersections
++
;
if
(
numberOfIntersections
%
2
==
0
)
{
if
(
numberOfIntersections
%
2
==
0
)
{
currVertex
++
;
currVertex
++
;
break
;
// the potential diagonal is fully outside, it's not an ear.
continue
;
// the potential diagonal is fully outside, it's not an ear.
}
}
//it's an ear!
//it's an ear!
...
...
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
register
or
sign in
to comment