Commit 85dd5159 by andy

### ENH: triangle - added cachedRandom random point function

parent ecd53eae
 ... @@ -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. ... ...
 ... @@ -244,6 +244,25 @@ inline Point Foam::triangle::randomPoint(Random& rndGen) const ... @@ -244,6 +244,25 @@ inline Point Foam::triangle::randomPoint(Random& rndGen) const } } template inline Point Foam::triangle::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 t = sqrt(rndGen.sample01()); return (1 - t)*a_ + (1 - s)*t*b_ + s*t*c_; } template template Foam::scalar Foam::triangle::barycentric Foam::scalar Foam::triangle::barycentric ( ( ... ...
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!