Go to the documentation of this file.
33 template<
class Po
int,
class Po
intRef>
47 template<
class Po
int,
class Po
intRef>
59 template<
class Po
int,
class Po
intRef>
62 const UList<Point>&
points,
63 const FixedList<label, 3>& indices
73 template<
class Po
int,
class Po
intRef>
82 template<
class Po
int,
class Po
intRef>
88 template<
class Po
int,
class Po
intRef>
94 template<
class Po
int,
class Po
intRef>
101 template<
class Po
int,
class Po
intRef>
104 return (1.0/3.0)*(a_ + b_ + c_);
108 template<
class Po
int,
class Po
intRef>
115 template<
class Po
int,
class Po
intRef>
118 return 0.5*((b_ - a_)^(c_ - a_));
122 template<
class Po
int,
class Po
intRef>
125 scalar d1 = (c_ - a_) & (b_ - a_);
126 scalar d2 = -(c_ - b_) & (b_ - a_);
127 scalar d3 = (c_ - a_) & (c_ - b_);
133 scalar
c =
c1 +
c2 + c3;
144 ((
c2 + c3)*a_ + (c3 +
c1)*b_ + (
c1 +
c2)*c_)/(2*
c)
149 template<
class Po
int,
class Po
intRef>
152 scalar d1 = (c_ - a_) & (b_ - a_);
153 scalar d2 = -(c_ - b_) & (b_ - a_);
154 scalar d3 = (c_ - a_) & (c_ - b_);
156 scalar denom = d2*d3 + d3*d1 + d1*d2;
166 scalar a = (d1 + d2)*(d2 + d3)*(d3 + d1) / denom;
173 template<
class Po
int,
class Po
intRef>
176 scalar
c = circumRadius();
188 template<
class Po
int,
class Po
intRef>
196 ((t.
a_ - a_) & ((b_ - a_)^(c_ - a_)))
197 + ((t.
b_ - b_) & ((c_ - b_)^(t.
a_ - b_)))
198 + ((c_ - t.
c_) & ((t.
b_ - t.
c_)^(t.
a_ - t.
c_)))
200 + ((t.
a_ - a_) & ((b_ - a_)^(c_ - a_)))
201 + ((b_ - t.
b_) & ((t.
a_ - t.
b_)^(t.
c_ - t.
b_)))
202 + ((c_ - t.
c_) & ((b_ - t.
c_)^(t.
a_ - t.
c_)))
207 template<
class Po
int,
class Po
intRef>
214 Point aRel = a_ - refPt;
215 Point bRel = b_ - refPt;
216 Point cRel = c_ - refPt;
220 aRel.x(), aRel.y(), aRel.z(),
221 bRel.x(), bRel.y(), bRel.z(),
222 cRel.x(), cRel.y(), cRel.z()
225 scalar a =
Foam::mag((b_ - a_)^(c_ - a_));
227 tensor S = 1/24.0*(tensor::one +
I);
236 + ((aRel + bRel + cRel) & (aRel + bRel + cRel))
244 template<
class Po
int,
class Po
intRef>
256 return (1 - t)*a_ + (1 -
s)*t*b_ +
s*t*c_;
260 template<
class Po
int,
class Po
intRef>
271 scalar
s =
rndGen.sample01<scalar>();
275 return (1 - t)*a_ + (1 -
s)*t*b_ +
s*t*c_;
279 template<
class Po
int,
class Po
intRef>
293 scalar d00 = v0 & v0;
294 scalar d01 = v0 & v1;
295 scalar d11 = v1 & v1;
296 scalar d20 = v2 & v0;
297 scalar d21 = v2 & v1;
299 scalar denom = d00*d11 - d01*d01;
312 bary[1] = (d11*d20 - d01*d21)/denom;
313 bary[2] = (d00*d21 - d01*d20)/denom;
314 bary[0] = 1.0 - bary[1] - bary[2];
320 template<
class Po
int,
class Po
intRef>
358 if (dir == intersection::CONTACT_SPHERE)
362 return ray(
p, q1 -
n, alg, intersection::VECTOR);
373 hit = fastInter.
hit();
383 pInter =
p + (q1&v)*q1;
388 scalar dist = q1 & (pInter -
p);
390 const scalar planarPointTol =
399 )*intersection::planarTol();
402 alg == intersection::FULL_RAY
403 || (alg == intersection::HALF_RAY && dist > -planarPointTol)
405 alg == intersection::VISIBLE
406 && ((q1 &
normal()) < -VSMALL)
422 inter.
setPoint(nearestPoint(
p).rawPoint());
436 template<
class Po
int,
class Po
intRef>
445 const vector edge1 = b_ - a_;
446 const vector edge2 = c_ - a_;
449 const vector pVec = dir ^ edge2;
452 const scalar
det = edge1 & pVec;
457 if (alg == intersection::VISIBLE)
460 if (
det < ROOTVSMALL)
466 else if (alg == intersection::HALF_RAY || alg == intersection::FULL_RAY)
469 if (
det > -ROOTVSMALL &&
det < ROOTVSMALL)
476 const scalar inv_det = 1.0 /
det;
479 const vector tVec = orig-a_;
482 const scalar u = (tVec & pVec)*inv_det;
484 if (u < -tol || u > 1.0+tol)
491 const vector qVec = tVec ^ edge1;
494 const scalar v = (dir & qVec) * inv_det;
496 if (v < -tol || u + v > 1.0+tol)
503 const scalar t = (edge2 & qVec) * inv_det;
505 if (alg == intersection::HALF_RAY && t < -tol)
519 template<
class Po
int,
class Po
intRef>
538 if (d1 <= 0.0 && d2 <= 0.0)
552 if (d3 >= 0.0 && d4 <= d3)
562 scalar vc = d1*d4 - d3*d2;
564 if (vc <= 0.0 && d1 >= 0.0 && d3 <= 0.0)
566 if ((d1 - d3) < ROOTVSMALL)
575 scalar v = d1/(d1 - d3);
577 point nearPt = a_ + v*ab;
588 if (d6 >= 0.0 && d5 <= d6)
598 scalar vb = d5*d2 - d1*d6;
600 if (vb <= 0.0 && d2 >= 0.0 && d6 <= 0.0)
602 if ((d2 - d6) < ROOTVSMALL)
611 scalar
w = d2/(d2 - d6);
620 scalar va = d3*d6 - d5*d4;
622 if (va <= 0.0 && (d4 - d3) >= 0.0 && (d5 - d6) >= 0.0)
624 if (((d4 - d3) + (d5 - d6)) < ROOTVSMALL)
634 scalar
w = (d4 - d3)/((d4 - d3) + (d5 - d6));
636 point nearPt = b_ +
w*(c_ - b_);
645 if ((va + vb + vc) < ROOTVSMALL)
649 point nearPt = centre();
655 scalar denom = 1.0/(va + vb + vc);
656 scalar v = vb * denom;
657 scalar
w = vc * denom;
661 point nearPt = a_ + ab*v + ac*
w;
668 template<
class Po
int,
class Po
intRef>
676 label nearLabel = -1;
678 return nearestPointClassify(
p, nearType, nearLabel);
682 template<
class Po
int,
class Po
intRef>
690 return nearestPointClassify(
p, nearType, nearLabel).hit();
694 template<
class Po
int,
class Po
intRef>
708 intersection::FULL_RAY
715 if (triInfo.distance() > 1)
722 triInfo.setMiss(
true);
723 triInfo.setDistance(dist);
725 else if (triInfo.distance() < 0)
732 triInfo.setMiss(
true);
733 triInfo.setDistance(dist);
739 lnInfo.
setPoint(triInfo.hitPoint());
741 triInfo.setDistance(0.0);
748 point nearestEdgePoint;
749 point nearestLinePoint;
751 scalar minDist =
ln.nearestDist
761 scalar dist =
ln.nearestDist
770 nearestEdgePoint = triEdgePoint;
771 nearestLinePoint = linePoint;
779 scalar dist =
ln.nearestDist
788 nearestEdgePoint = triEdgePoint;
789 nearestLinePoint = linePoint;
795 triInfo.setDistance(minDist);
796 triInfo.setMiss(
false);
797 triInfo.setPoint(nearestEdgePoint);
800 if (
Foam::mag(nearestLinePoint-
ln.start()) < SMALL)
805 else if (
Foam::mag(nearestLinePoint-
ln.end()) < SMALL)
820 template<
class Po
int,
class Po
intRef>
828 template<
class Po
int,
class Po
intRef>
835 template<
class Po
int,
class Po
intRef>
845 template<
class Po
int,
class Po
intRef>
857 template<
class Po
int,
class Po
intRef>
863 tris_[nTris_++] = tri;
867 template<
class Po
int,
class Po
intRef>
876 return (d[posI]*t[negI] - d[negI]*t[posI])/(-d[negI] + d[posI]);
882 template<
class Po
int,
class Po
intRef>
890 is >> t.a_ >> t.b_ >> t.c_;
891 is.readEnd(
"triangle");
893 is.check(
"Istream& operator>>(Istream&, triangle&)");
898 template<
class Po
int,
class Po
intRef>
902 const triangle<Point, PointRef>& t
Simple random number generator.
Templated 3D tensor derived from VectorSpace adding construction from 9 components,...
void setMiss(const bool eligible)
Useful combination of include files which define Sin, Sout and Serr and the use of IO streams general...
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
bool hit() const
Is there a hit.
Point randomPoint(Random &rndGen) const
Return a random point on the triangle from a uniform.
This class describes the interaction of a face and a point. It carries the info of a successful hit a...
static point planeIntersection(const FixedList< scalar, 3 > &d, const triPoints &t, const label negI, const label posI)
Helper: calculate intersection point.
bool classify(const point &p, label &nearType, label &nearLabel) const
Classify nearest point to p in triangle plane.
const Point & rawPoint() const
Return point with no checking.
tensor inertia(PointRef refPt=vector::zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
dimensioned< scalar > mag(const dimensioned< Type > &)
Point centre() const
Return centre (centroid)
scalar barycentric(const point &pt, List< scalar > &bary) const
Calculate the barycentric coordinates of the given.
A triangle primitive used to calculate face normals and swept volumes.
Triangle storage. Null constructable (unfortunately triangle<point, point> is not)
const dimensionedScalar c1
First radiation constant: default SI units: [W/m2].
const Point & c() const
Return third vertex.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
vector normal() const
Return vector normal.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
void setPoint(const Point &p)
const Point & a() const
Return first vertex.
pointHit ray(const point &p, const vector &q, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction dir=intersection::VECTOR) const
Return point intersection with a ray.
const volScalarField & cp
static const sphericalTensor I(1)
const Point & b() const
Return second vertex.
scalar circumRadius() const
Return circum-radius.
PointHit< point > pointHit
const dimensionedScalar c2
Second radiation constant: default SI units: [m.K].
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().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))
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
scalar mag() const
Return scalar magnitude.
pointHit nearestPointClassify(const point &p, label &nearType, label &nearLabel) const
Find the nearest point to p on the triangle and classify it:
void setSize(const label)
Reset size of List.
line< point, const point & > linePointRef
Line using referred points.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
scalar quality() const
Return quality: Ratio of triangle and circum-circle.
Point circumCentre() const
Return circum-centre.
dimensionedScalar sqrt(const dimensionedScalar &ds)
A 1D vector of objects of type <T> with a fixed size <Size>.
pointHit intersection(const point &p, const vector &q, const intersection::algorithm alg, const scalar tol=0.0) const
Fast intersection with a ray.
triangle(const Point &a, const Point &b, const Point &c)
Construct from three points.
const dimensionedScalar c
Speed of light in a vacuum.
bool ln(const fileName &src, const fileName &dst)
Create a softlink. dst should not exist. Returns true if successful.
pointHit nearestPoint(const point &p) const
Return nearest point to p on triangle.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Istream & readBegin(const char *funcName)
vector point
Point is a vector.
const Point & missPoint() const
Return miss point.
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
cachedRandom rndGen(label(0), -1)
scalar sweptVol(const triangle &t) const
Return swept-volume.
A normal distribution model.
storeOp(triIntersectionList &, label &)
void setDistance(const scalar d)
Tensor< Cmpt > T() const
Transpose.