31 void Foam::plane::calcPntAndVec(
const scalarList& C)
33 normal_ =
vector(C[0], C[1], C[2]);
35 const scalar magNormal =
mag(normal_);
40 <<
"Plane normal has zero length" 46 if (magNormal <
mag(C[3])*vSmall)
49 <<
"Plane is too far from the origin" 53 point_ = - C[3]/magNormal*normal_;
57 void Foam::plane::calcPntAndVec
64 point_ = (point1 + point2 + point3)/3;
65 vector line12 = point1 - point2;
66 vector line23 = point2 - point3;
71 ||
mag(line23) < vSmall
72 ||
mag(point3-point1) < vSmall
76 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
80 normal_ = line12 ^ line23;
81 scalar magUnitVector(
mag(normal_));
83 if (magUnitVector < vSmall)
86 <<
"Plane normal defined with zero length" <<
nl 87 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
91 normal_ /= magUnitVector;
99 normal_(normalVector),
102 scalar magUnitVector(
mag(normal_));
104 if (magUnitVector > vSmall)
106 normal_ /= magUnitVector;
111 <<
"plane normal has zero length. basePoint:" << point_
119 normal_(normalVector),
122 scalar magUnitVector(
mag(normal_));
124 if (magUnitVector > vSmall)
126 normal_ /= magUnitVector;
131 <<
"plane normal has zero length. basePoint:" << point_
150 calcPntAndVec(a, b, c);
159 const word planeType(dict.
lookup(
"planeType"));
161 if (planeType ==
"planeEquation")
166 C[0] = subDict.
lookup<scalar>(
"a");
167 C[1] = subDict.
lookup<scalar>(
"b");
168 C[2] = subDict.
lookup<scalar>(
"c");
169 C[3] = subDict.
lookup<scalar>(
"d");
174 else if (planeType ==
"embeddedPoints")
182 calcPntAndVec(point1, point2, point3);
184 else if (planeType ==
"pointAndNormal")
189 subDict.
found(
"basePoint")
190 ? subDict.
lookup(
"basePoint")
191 : subDict.
lookup(
"point");
194 subDict.
found(
"normalVector")
195 ? subDict.
lookup(
"normalVector")
196 : subDict.
lookup(
"normal");
198 normal_ /=
mag(normal_);
203 <<
"Invalid plane type: " << planeType <<
nl 204 <<
"Valid options include: planeEquation, embeddedPoints and " 216 scalar magUnitVector(
mag(normal_));
218 if (magUnitVector > vSmall)
220 normal_ /= magUnitVector;
225 <<
"plane normal has zero length. basePoint:" << point_
249 scalar magX =
mag(normal_.
x());
250 scalar magY =
mag(normal_.
y());
251 scalar magZ =
mag(normal_.
z());
258 C[1] = normal_.
y()/normal_.
x();
259 C[2] = normal_.
z()/normal_.
x();
263 C[0] = normal_.
x()/normal_.
z();
264 C[1] = normal_.
y()/normal_.
z();
272 C[0] = normal_.
x()/normal_.
y();
274 C[2] = normal_.
z()/normal_.
y();
278 C[0] = normal_.
x()/normal_.
z();
279 C[1] = normal_.
y()/normal_.
z();
284 C[3] = - C[0] * point_.
x()
300 const scalar perturbX = refPt.
x() + 1
e-3;
301 const scalar perturbY = refPt.
y() + 1
e-3;
302 const scalar perturbZ = refPt.
z() + 1
e-3;
304 if (
mag(planeCoeffs[2]) < small)
306 if (
mag(planeCoeffs[1]) < small)
312 + planeCoeffs[1]*perturbY
313 + planeCoeffs[2]*perturbZ
328 + planeCoeffs[0]*perturbX
329 + planeCoeffs[2]*perturbZ
345 + planeCoeffs[0]*perturbX
346 + planeCoeffs[1]*perturbY
361 return p - normal_*((p - point_) & normal_);
367 return mag((p - point_) & normal_);
377 const scalar num = (point_ - pnt0) & normal_;
378 const scalar den = dir & normal_;
380 return mag(den) >
mag(num)*vSmall ? num/den : vGreat;
404 scalar magX =
mag(dir.
x());
405 scalar magY =
mag(dir.
y());
406 scalar magZ =
mag(dir.
z());
444 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
445 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
463 coeffs1[0],coeffs1[1],coeffs1[2],
464 coeffs2[0],coeffs2[1],coeffs2[2],
465 coeffs3[0],coeffs3[1],coeffs3[2]
468 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
470 return (
inv(a) & (-b));
476 const scalar angle((p - point_) & normal_);
486 if ((
normal() & mirroredPtDir) > 0)
499 writeEntry(os,
"planeType",
"pointAndNormal");
500 os <<
indent <<
"pointAndNormalDict" <<
nl 512 if (a.point_ == b.point_ && a.normal_ == b.normal_)
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Ostream & indent(Ostream &os)
Indent stream.
A direction and a reference point.
A 1D vector of objects of type <T> with a fixed size <Size>.
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
point nearestPoint(const point &p) const
Return nearest point in the plane for the given point.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Ostream & endl(Ostream &os)
Add newline and flush stream.
ray planeIntersect(const plane &) const
Return the cutting line between this plane and another.
point planePlaneIntersect(const plane &, const plane &) const
Return the cutting point between this plane and two other planes.
Vector< scalar > vector
A scalar version of the templated Vector.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
plane(const vector &normalVector)
Construct from normal vector through the origin.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
side sideOfPlane(const point &p) const
Return the side of the plane that the point is on.
scalar normalIntersect(const point &pnt0, const vector &dir) const
Return cut coefficient for plane and line defined by.
const dimensionedScalar & b
Wien displacement law constant: default SI units: [m K].
point aPoint() const
Return a point on the plane.
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
const point & refPoint() const
Return or return plane base point.
List< scalar > scalarList
A List of scalars.
scalar distance(const point &p) const
Return distance from the given point to the plane.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
point mirror(const point &p) const
Mirror the supplied point in the plane. Return the mirrored point.
const vector & normal() const
Return plane normal.
vector point
Point is a vector.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Ostream & operator<<(Ostream &, const ensightPart &)
void writeDict(Ostream &) const
Write to dictionary.
dimensioned< scalar > mag(const dimensioned< Type > &)
const doubleScalar e
Elementary charge.
FixedList< scalar, 4 > planeCoeffs() const
Return coefficients for the.
bool operator!=(const particle &, const particle &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.