36template<
class Po
int,
class Po
intRef>
50template<
class Po
int,
class Po
intRef>
62template<
class Po
int,
class Po
intRef>
76template<
class Po
int,
class Po
intRef>
85template<
class Po
int,
class Po
intRef>
91template<
class Po
int,
class Po
intRef>
97template<
class Po
int,
class Po
intRef>
104template<
class Po
int,
class Po
intRef>
107 return (1.0/3.0)*(a_ + b_ + c_);
111template<
class Po
int,
class Po
intRef>
114 return 0.5*((b_ - a_)^(c_ - a_));
118template<
class Po
int,
class Po
intRef>
123 return s < ROOTVSMALL ?
Zero :
n/
s;
127template<
class Po
int,
class Po
intRef>
130 return ::Foam::mag(areaNormal());
134template<
class Po
int,
class Po
intRef>
137 scalar d1 = (c_ - a_) & (b_ - a_);
138 scalar d2 = -(c_ - b_) & (b_ - a_);
139 scalar d3 = (c_ - a_) & (c_ - b_);
145 scalar c = c1 + c2 + c3;
156 ((c2 + c3)*a_ + (c3 + c1)*b_ + (c1 + c2)*c_)/(2*c)
161template<
class Po
int,
class Po
intRef>
164 const scalar d1 = (c_ - a_) & (b_ - a_);
165 const scalar d2 = -(c_ - b_) & (b_ - a_);
166 const scalar d3 = (c_ - a_) & (c_ - b_);
168 const scalar denom = d2*d3 + d3*d1 + d1*d2;
177 const scalar a = (d1 + d2)*(d2 + d3)*(d3 + d1) / denom;
182template<
class Po
int,
class Po
intRef>
185 scalar c = circumRadius();
197template<
class Po
int,
class Po
intRef>
205 ((t.a_ - a_) & ((b_ - a_)^(c_ - a_)))
206 + ((t.b_ - b_) & ((c_ - b_)^(t.a_ - b_)))
207 + ((c_ - t.c_) & ((t.b_ - t.c_)^(t.a_ - t.c_)))
209 + ((t.a_ - a_) & ((b_ - a_)^(c_ - a_)))
210 + ((b_ - t.b_) & ((t.a_ - t.b_)^(t.c_ - t.b_)))
211 + ((c_ - t.c_) & ((b_ - t.c_)^(t.a_ - t.c_)))
216template<
class Po
int,
class Po
intRef>
223 Point aRel = a_ - refPt;
224 Point bRel = b_ - refPt;
225 Point cRel = c_ - refPt;
229 aRel.x(), aRel.y(), aRel.z(),
230 bRel.x(), bRel.y(), bRel.z(),
231 cRel.x(), cRel.y(), cRel.z()
234 scalar a =
Foam::mag((b_ - a_)^(c_ - a_));
245 + ((aRel + bRel + cRel) & (aRel + bRel + cRel))
253template<
class Po
int,
class Po
intRef>
260template<
class Po
int,
class Po
intRef>
266 return bary[0]*a_ + bary[1]*b_ + bary[2]*c_;
270template<
class Po
int,
class Po
intRef>
277 pointToBarycentric(pt, bary);
282template<
class Po
int,
class Po
intRef>
296 scalar d00 = v0 & v0;
297 scalar d01 = v0 & v1;
298 scalar d11 = v1 & v1;
299 scalar d20 = v2 & v0;
300 scalar d21 = v2 & v1;
302 scalar denom = d00*d11 - d01*d01;
313 bary[1] = (d11*d20 - d01*d21)/denom;
314 bary[2] = (d00*d21 - d01*d20)/denom;
315 bary[0] = 1.0 - bary[1] - bary[2];
321template<
class Po
int,
class Po
intRef>
374 hit = fastInter.
hit();
384 pInter =
p + (q1&v)*q1;
389 scalar dist = q1 & (pInter -
p);
391 const scalar planarPointTol =
407 && ((q1 & areaNormal()) < -VSMALL)
423 inter.
setPoint(nearestPoint(
p).rawPoint());
437template<
class Po
int,
class Po
intRef>
446 const vector edge1 = b_ - a_;
447 const vector edge2 = c_ - a_;
450 const vector pVec = dir ^ edge2;
453 const scalar
det = edge1 & pVec;
461 if (
det < ROOTVSMALL)
470 if (
det > -ROOTVSMALL &&
det < ROOTVSMALL)
477 const scalar inv_det = 1.0 /
det;
480 const vector tVec = orig-a_;
483 const scalar u = (tVec & pVec)*inv_det;
485 if (u < -tol || u > 1.0+tol)
492 const vector qVec = tVec ^ edge1;
495 const scalar v = (dir & qVec) * inv_det;
497 if (v < -tol || u + v > 1.0+tol)
504 const scalar t = (edge2 & qVec) * inv_det;
520template<
class Po
int,
class Po
intRef>
539 if (d1 <= 0.0 && d2 <= 0.0)
553 if (d3 >= 0.0 && d4 <= d3)
563 scalar vc = d1*d4 - d3*d2;
565 if (vc <= 0.0 && d1 >= 0.0 && d3 <= 0.0)
567 if ((d1 - d3) < ROOTVSMALL)
576 scalar v = d1/(d1 - d3);
578 point nearPt = a_ + v*ab;
589 if (d6 >= 0.0 && d5 <= d6)
599 scalar vb = d5*d2 - d1*d6;
601 if (vb <= 0.0 && d2 >= 0.0 && d6 <= 0.0)
603 if ((d2 - d6) < ROOTVSMALL)
612 scalar w = d2/(d2 - d6);
614 point nearPt = a_ + w*ac;
621 scalar va = d3*d6 - d5*d4;
623 if (va <= 0.0 && (d4 - d3) >= 0.0 && (d5 - d6) >= 0.0)
625 if (((d4 - d3) + (d5 - d6)) < ROOTVSMALL)
635 scalar w = (d4 - d3)/((d4 - d3) + (d5 - d6));
637 point nearPt = b_ + w*(c_ - b_);
646 if ((va + vb + vc) < ROOTVSMALL)
650 point nearPt = centre();
656 scalar denom = 1.0/(va + vb + vc);
657 scalar v = vb * denom;
658 scalar w = vc * denom;
662 point nearPt = a_ + ab*v + ac*w;
669template<
class Po
int,
class Po
intRef>
677 label nearLabel = -1;
679 return nearestPointClassify(
p, nearType, nearLabel);
683template<
class Po
int,
class Po
intRef>
691 return nearestPointClassify(
p, nearType, nearLabel).hit();
695template<
class Po
int,
class Po
intRef>
749 point nearestEdgePoint;
750 point nearestLinePoint;
752 scalar minDist =
ln.nearestDist
762 scalar dist =
ln.nearestDist
771 nearestEdgePoint = triEdgePoint;
772 nearestLinePoint = linePoint;
780 scalar dist =
ln.nearestDist
789 nearestEdgePoint = triEdgePoint;
790 nearestLinePoint = linePoint;
801 if (
Foam::mag(nearestLinePoint-
ln.start()) < SMALL)
806 else if (
Foam::mag(nearestLinePoint-
ln.end()) < SMALL)
821template<
class Po
int,
class Po
intRef>
828 const scalar dist = ((
p - a_) & unitNormal());
830 return ((dist < -tol) ? -1 : (dist > tol) ? +1 : 0);
834template<
class Po
int,
class Po
intRef>
842template<
class Po
int,
class Po
intRef>
849template<
class Po
int,
class Po
intRef>
859template<
class Po
int,
class Po
intRef>
871template<
class Po
int,
class Po
intRef>
877 tris_[nTris_++] = tri;
881template<
class Po
int,
class Po
intRef>
890 return (d[posI]*t[negI] - d[negI]*t[posI])/(-d[negI] + d[posI]);
896template<
class Po
int,
class Po
intRef>
904 is >> t.a_ >> t.b_ >> t.c_;
905 is.readEnd(
"triangle");
912template<
class Po
int,
class Po
intRef>
916 const triangle<Point, PointRef>& t
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
Templated 2D Barycentric derived from VectorSpace. Has 3 components, one of which is redundant.
A 1D vector of objects of type <T> with a fixed length <N>.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
bool readBegin(const char *funcName)
Begin read of data chunk, starts with '('.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Describes the interaction of a face and a point. It carries the info of a successful hit and (if succ...
void setHit() noexcept
Set the hit status on.
const point_type & rawPoint() const noexcept
The point, no checks.
scalar distance() const noexcept
Return distance to hit.
void setPoint(const point_type &p)
Set the point.
void setDistance(const scalar d) noexcept
Set the distance.
const point_type & missPoint() const
Return the miss point. Fatal if hit.
bool hit() const noexcept
Is there a hit.
void setMiss(const bool eligible) noexcept
Set the hit status off and set the eligible miss status.
const point_type & hitPoint() const
Return the hit point. Fatal if not hit.
Tensor< Cmpt > T() const
Return non-Hermitian transpose.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
friend complex sign(const complex &c)
sgn() https://en.wikipedia.org/wiki/Sign_function#Complex_signum
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
static scalar planarTol()
Return planar tolerance.
A class representing the concept of 1 (one) that can be used to avoid manipulating objects known to b...
A reference point and direction.
@ BEGIN_LIST
Begin list [isseparator].
@ END_LIST
End list [isseparator].
Triangle storage. Null constructable (unfortunately triangle<point, point> is not)
A triangle primitive used to calculate face normals and swept volumes.
Point circumCentre() const
Return circum-centre.
barycentric2D pointToBarycentric(const point &pt) const
Calculate the barycentric coordinates from the given point.
scalar circumRadius() const
Return circum-radius.
Point barycentricToPoint(const barycentric2D &bary) const
Calculate the point from the given barycentric coordinates.
scalar sweptVol(const triangle &t) const
Return swept-volume.
vector areaNormal() const
The area normal - with magnitude equal to area of triangle.
const Point & a() const
Return first vertex.
Point centre() const
Return centre (centroid)
pointHit nearestPointClassify(const point &p, label &nearType, label &nearLabel) const
Find the nearest point to p on the triangle and classify it:
vector unitNormal() const
Return unit normal.
const Point & c() const
Return third vertex.
tensor inertia(PointRef refPt=Zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
scalar mag() const
Return scalar magnitude.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform.
bool classify(const point &p, label &nearType, label &nearLabel) const
Classify nearest point to p in triangle plane.
const Point & b() const
Return second vertex.
scalar quality() const
Return quality: Ratio of triangle and circum-circle.
OBJstream os(runTime.globalPath()/outputName)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
dimensionedScalar det(const dimensionedSphericalTensor &dt)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
barycentric2D barycentric2D01(Random &rndGen)
Generate a random barycentric coordinate within the unit triangle.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
line< point, const point & > linePointRef
A line using referred points.
static const Identity< scalar > I
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
PointHit< point > pointHit
A PointIndexHit for 3D points.
static constexpr const zero Zero
Global zero (0)
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
constexpr char nl
The newline '\n' character (0x0a)
const volScalarField & cp