Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MostafaMollaali
dynamic
Commits
ce4911e3
Commit
ce4911e3
authored
6 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[GL] Use exact predicate for 2D orientation.
The predicate is correct but slower than the homegrown solution.
parent
52e4d1bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/AnalyticalGeometry.cpp
+10
-20
10 additions, 20 deletions
GeoLib/AnalyticalGeometry.cpp
GeoLib/AnalyticalGeometry.h
+6
-13
6 additions, 13 deletions
GeoLib/AnalyticalGeometry.h
with
16 additions
and
33 deletions
GeoLib/AnalyticalGeometry.cpp
+
10
−
20
View file @
ce4911e3
...
...
@@ -44,25 +44,15 @@ double getOrientation2d(MathLib::Point3d const& a,
namespace
GeoLib
{
Orientation
getOrientation
(
const
double
&
p0_x
,
const
double
&
p0_y
,
const
double
&
p1_x
,
const
double
&
p1_y
,
const
double
&
p2_x
,
const
double
&
p2_y
)
{
double
h1
((
p1_x
-
p0_x
)
*
(
p2_y
-
p0_y
));
double
h2
((
p2_x
-
p0_x
)
*
(
p1_y
-
p0_y
));
double
tol
(
std
::
numeric_limits
<
double
>::
epsilon
());
if
(
fabs
(
h1
-
h2
)
<=
tol
*
std
::
max
(
fabs
(
h1
),
fabs
(
h2
)))
return
COLLINEAR
;
if
(
h1
-
h2
>
0.0
)
return
CCW
;
return
CW
;
}
Orientation
getOrientation
(
const
GeoLib
::
Point
*
p0
,
const
GeoLib
::
Point
*
p1
,
const
GeoLib
::
Point
*
p2
)
{
return
getOrientation
((
*
p0
)[
0
],
(
*
p0
)[
1
],
(
*
p1
)[
0
],
(
*
p1
)[
1
],
(
*
p2
)[
0
],
(
*
p2
)[
1
]);
double
const
orientation
=
ExactPredicates
::
getOrientation2d
(
*
p0
,
*
p1
,
*
p2
);
if
(
orientation
>
0
)
return
CCW
;
if
(
orientation
<
0
)
return
CW
;
return
COLLINEAR
;
}
bool
parallel
(
MathLib
::
Vector3
v
,
MathLib
::
Vector3
w
)
...
...
@@ -380,8 +370,8 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d(
GeoLib
::
Point
const
&
c
{
cd
.
getBeginPoint
()};
GeoLib
::
Point
const
&
d
{
cd
.
getEndPoint
()};
double
const
orient_abc
(
ExactPredicates
::
getOrientation
2d
(
a
,
b
,
c
));
double
const
orient_abd
(
ExactPredicates
::
getOrientation
2d
(
a
,
b
,
d
));
double
const
orient_abc
(
getOrientation
(
a
,
b
,
c
));
double
const
orient_abd
(
getOrientation
(
a
,
b
,
d
));
// check if the segment (cd) lies on the left or on the right of (ab)
if
((
orient_abc
>
0
&&
orient_abd
>
0
)
||
(
orient_abc
<
0
&&
orient_abd
<
0
))
{
...
...
@@ -497,8 +487,8 @@ std::vector<MathLib::Point3d> lineSegmentIntersect2d(
}
// check if the segment (ab) lies on the left or on the right of (cd)
double
const
orient_cda
(
ExactPredicates
::
getOrientation
2d
(
c
,
d
,
a
));
double
const
orient_cdb
(
ExactPredicates
::
getOrientation
2d
(
c
,
d
,
b
));
double
const
orient_cda
(
getOrientation
(
c
,
d
,
a
));
double
const
orient_cdb
(
getOrientation
(
c
,
d
,
b
));
if
((
orient_cda
>
0
&&
orient_cdb
>
0
)
||
(
orient_cda
<
0
&&
orient_cdb
<
0
))
{
return
std
::
vector
<
MathLib
::
Point3d
>
();
}
...
...
This diff is collapsed.
Click to expand it.
GeoLib/AnalyticalGeometry.h
+
6
−
13
View file @
ce4911e3
...
...
@@ -37,20 +37,13 @@ enum Orientation
};
/**
*
c
omputes the orientation of the three 2D-Points
given by their coordinates
*
p0_x, p0_y, p1_x, p1_y, p2_x and p2_y
*
\returns CW (clockwise), CCW (counterclockwise) or COLLINEAR (points are on a
line)
*
C
omputes the orientation of the three 2D-Points
.
*
\returns CW (clockwise), CCW (counterclockwise) or COLLINEAR (points are on a
* line)
*/
Orientation
getOrientation
(
const
double
&
p0_x
,
const
double
&
p0_y
,
const
double
&
p1_x
,
const
double
&
p1_y
,
const
double
&
p2_x
,
const
double
&
p2_y
);
/**
* wrapper for getOrientation ()
*/
Orientation
getOrientation
(
const
GeoLib
::
Point
*
p0
,
const
GeoLib
::
Point
*
p1
,
const
GeoLib
::
Point
*
p2
);
Orientation
getOrientation
(
const
GeoLib
::
Point
*
p0
,
const
GeoLib
::
Point
*
p1
,
const
GeoLib
::
Point
*
p2
);
/**
* compute a supporting plane (represented by plane_normal and the value d) for the polygon
...
...
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