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
5f5603d3
Commit
5f5603d3
authored
3 years ago
by
Kilian Weishaupt
Committed by
Ned Coltman
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[geometry] Add function to calculate circumsphere of trinangle
parent
173d0648
No related branches found
No related tags found
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dumux/geometry/circumsphere.hh
+64
-0
64 additions, 0 deletions
dumux/geometry/circumsphere.hh
with
64 additions
and
0 deletions
dumux/geometry/circumsphere.hh
0 → 100644
+
64
−
0
View file @
5f5603d3
/*****************************************************************************
* See the file COPYING for full copying permissions. *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*****************************************************************************/
/*!
* \file
* \ingroup Geometry
* \brief A function to compute the circumsphere of a given geometry
* \note The circumscribed sphere (or circumsphere) is a sphere touching all vertices of the geometry
* Therefore it does not necessarily exist for all geometries.
*/
#ifndef DUMUX_GEOMETRY_CIRCUMSPHERE_HH
#define DUMUX_GEOMETRY_CIRCUMSPHERE_HH
#include
<type_traits>
#include
<dumux/common/math.hh>
#include
<dumux/geometry/sphere.hh>
namespace
Dumux
{
/*!
* \ingroup Geometry
* \brief Computes the circumsphere of a triangle
* \note See https://www.ics.uci.edu/~eppstein/junkyard/circumcenter.html
*/
template
<
class
Point
>
static
inline
Sphere
<
typename
Point
::
value_type
,
Point
::
dimension
>
circumSphereOfTriangle
(
const
Point
&
a
,
const
Point
&
b
,
const
Point
&
c
)
{
const
auto
ac
=
c
-
a
;
const
auto
ab
=
b
-
a
;
const
auto
n
=
crossProduct
(
ab
,
ac
);
const
auto
distCenterToA
=
(
crossProduct
(
n
,
ab
)
*
ac
.
two_norm2
()
+
crossProduct
(
ac
,
n
)
*
ab
.
two_norm2
())
/
(
2.0
*
n
.
two_norm2
());
return
{
a
+
distCenterToA
,
distCenterToA
.
two_norm
()
};
}
/*!
* \ingroup Geometry
* \brief Computes the circumsphere of a triangle
*/
template
<
class
Geometry
,
typename
std
::
enable_if_t
<
Geometry
::
mydimension
==
2
,
int
>
=
0
>
static
inline
Sphere
<
typename
Geometry
::
ctype
,
Geometry
::
coorddimension
>
circumSphereOfTriangle
(
const
Geometry
&
triangle
)
{
assert
(
triangle
.
corners
()
==
3
&&
"Geometry is not a triangle."
);
return
circumSphereOfTriangle
(
triangle
.
corner
(
0
),
triangle
.
corner
(
1
),
triangle
.
corner
(
2
));
}
}
// end namespace Dumux
#endif
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