Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
dumux
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dumux-repositories
dumux
Commits
b9fb1feb
Commit
b9fb1feb
authored
6 years ago
by
Timo Koch
Browse files
Options
Downloads
Patches
Plain Diff
[geometry][2d][pointinsimplex] Compute correct epsilon to get points on the surface of the simplex
parent
c2973437
No related branches found
No related tags found
1 merge request
!1141
Fix/point in geometry 2d simplex
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/common/geometry/intersectspointsimplex.hh
+11
-7
11 additions, 7 deletions
dumux/common/geometry/intersectspointsimplex.hh
with
11 additions
and
7 deletions
dumux/common/geometry/intersectspointsimplex.hh
+
11
−
7
View file @
b9fb1feb
...
@@ -82,18 +82,20 @@ bool intersectsPointSimplex(const Dune::FieldVector<ctype, dimworld>& point,
...
@@ -82,18 +82,20 @@ bool intersectsPointSimplex(const Dune::FieldVector<ctype, dimworld>& point,
{
{
// adapted from the algorithm from from "Real-Time Collision Detection" by Christer Ericson,
// adapted from the algorithm from from "Real-Time Collision Detection" by Christer Ericson,
// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc. (Chapter 5.4.2)
// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc. (Chapter 5.4.2)
static
constexpr
ctype
eps_
=
1.0e-7
;
constexpr
ctype
eps_
=
1.0e-7
;
// compute the normal of the triangle
// compute the normal of the triangle
const
auto
v1
=
p0
-
p2
;
const
auto
v1
=
p0
-
p2
;
auto
n
=
crossProduct
(
v1
,
p1
-
p0
);
auto
n
=
crossProduct
(
v1
,
p1
-
p0
);
n
/=
n
.
two_norm
();
const
ctype
nnorm
=
n
.
two_norm
();
const
ctype
eps4
=
eps_
*
nnorm
*
nnorm
;
// compute an epsilon for later
n
/=
nnorm
;
// normalize
// first check if we are in the plane of the triangle
// first check if we are in the plane of the triangle
// if not we can return early
// if not we can return early
using
std
::
abs
;
using
std
::
abs
;
auto
x
=
p0
-
point
;
auto
x
=
p0
-
point
;
x
/=
x
.
two_norm
();
x
/=
x
.
two_norm
();
// normalize
if
(
abs
(
x
*
n
)
>
eps_
)
if
(
abs
(
x
*
n
)
>
eps_
)
return
false
;
return
false
;
...
@@ -107,14 +109,16 @@ bool intersectsPointSimplex(const Dune::FieldVector<ctype, dimworld>& point,
...
@@ -107,14 +109,16 @@ bool intersectsPointSimplex(const Dune::FieldVector<ctype, dimworld>& point,
const
auto
u
=
crossProduct
(
b
,
c
);
const
auto
u
=
crossProduct
(
b
,
c
);
const
auto
v
=
crossProduct
(
c
,
a
);
const
auto
v
=
crossProduct
(
c
,
a
);
// they have to point in the same direction
// they have to point in the same direction or be orthogonal
if
(
u
*
v
<
0.0
)
return
false
;
if
(
u
*
v
<
0.0
-
eps4
)
return
false
;
// compute the normal vector for triangle P->C->A
// compute the normal vector for triangle P->C->A
const
auto
w
=
crossProduct
(
a
,
b
);
const
auto
w
=
crossProduct
(
a
,
b
);
// it also has to point in the same direction
// it also has to point in the same direction or be orthogonal
if
(
u
*
w
<
0.0
)
return
false
;
if
(
u
*
w
<
0.0
-
eps4
)
return
false
;
// now the point must be in the triangle (or on the faces)
// now the point must be in the triangle (or on the faces)
return
true
;
return
true
;
...
...
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