Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
85dd5159
Commit
85dd5159
authored
Jul 12, 2013
by
andy
Browse files
ENH: triangle - added cachedRandom random point function
parent
ecd53eae
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/meshes/primitiveShapes/triangle/triangle.H
View file @
85dd5159
...
@@ -40,6 +40,7 @@ SourceFiles
...
@@ -40,6 +40,7 @@ SourceFiles
#include
"tensor.H"
#include
"tensor.H"
#include
"pointHit.H"
#include
"pointHit.H"
#include
"Random.H"
#include
"Random.H"
#include
"cachedRandom.H"
#include
"FixedList.H"
#include
"FixedList.H"
#include
"UList.H"
#include
"UList.H"
#include
"linePointRef.H"
#include
"linePointRef.H"
...
@@ -162,6 +163,10 @@ public:
...
@@ -162,6 +163,10 @@ public:
// distribution
// distribution
inline
Point
randomPoint
(
Random
&
rndGen
)
const
;
inline
Point
randomPoint
(
Random
&
rndGen
)
const
;
//- Return a random point on the triangle from a uniform
// distribution
inline
Point
randomPoint
(
cachedRandom
&
rndGen
)
const
;
//- Calculate the barycentric coordinates of the given
//- Calculate the barycentric coordinates of the given
// point, in the same order as a, b, c. Returns the
// point, in the same order as a, b, c. Returns the
// determinant of the solution.
// determinant of the solution.
...
...
src/OpenFOAM/meshes/primitiveShapes/triangle/triangleI.H
View file @
85dd5159
...
@@ -244,6 +244,25 @@ inline Point Foam::triangle<Point, PointRef>::randomPoint(Random& rndGen) const
...
@@ -244,6 +244,25 @@ inline Point Foam::triangle<Point, PointRef>::randomPoint(Random& rndGen) const
}
}
template
<
class
Point
,
class
PointRef
>
inline
Point
Foam
::
triangle
<
Point
,
PointRef
>::
randomPoint
(
cachedRandom
&
rndGen
)
const
{
// Generating Random Points in Triangles
// by Greg Turk
// from "Graphics Gems", Academic Press, 1990
// http://tog.acm.org/GraphicsGems/gems/TriPoints.c
scalar
s
=
rndGen
.
sample01
<
scalar
>
();
scalar
t
=
sqrt
(
rndGen
.
sample01
<
scalar
>
());
return
(
1
-
t
)
*
a_
+
(
1
-
s
)
*
t
*
b_
+
s
*
t
*
c_
;
}
template
<
class
Point
,
class
PointRef
>
template
<
class
Point
,
class
PointRef
>
Foam
::
scalar
Foam
::
triangle
<
Point
,
PointRef
>::
barycentric
Foam
::
scalar
Foam
::
triangle
<
Point
,
PointRef
>::
barycentric
(
(
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment