31 void Foam::plane::calcPntAndVec(
const scalarList& C)
33 if (
mag(C[0]) > VSMALL)
35 point_ =
vector((-C[3]/C[0]), 0, 0);
39 if (
mag(C[1]) > VSMALL)
41 point_ =
vector(0, (-C[3]/C[1]), 0);
45 if (
mag(C[2]) > VSMALL)
47 point_ =
vector(0, 0, (-C[3]/C[2]));
52 <<
"At least one plane coefficient must have a value" 58 normal_ =
vector(C[0], C[1], C[2]);
59 scalar magUnitVector(
mag(normal_));
61 if (magUnitVector < VSMALL)
64 <<
"Plane normal defined with zero length" 68 normal_ /= magUnitVector;
72 void Foam::plane::calcPntAndVec
79 point_ = (point1 + point2 + point3)/3;
80 vector line12 = point1 - point2;
81 vector line23 = point2 - point3;
86 ||
mag(line23) < VSMALL
87 ||
mag(point3-point1) < VSMALL
91 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
95 normal_ = line12 ^ line23;
96 scalar magUnitVector(
mag(normal_));
98 if (magUnitVector < VSMALL)
101 <<
"Plane normal defined with zero length" <<
nl 102 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
106 normal_ /= magUnitVector;
114 normal_(normalVector),
117 scalar magUnitVector(
mag(normal_));
119 if (magUnitVector > VSMALL)
121 normal_ /= magUnitVector;
126 <<
"plane normal has zero length. basePoint:" << point_
134 normal_(normalVector),
137 scalar magUnitVector(
mag(normal_));
139 if (magUnitVector > VSMALL)
141 normal_ /= magUnitVector;
146 <<
"plane normal has zero length. basePoint:" << point_
165 calcPntAndVec(a, b, c);
174 const word planeType(dict.
lookup(
"planeType"));
176 if (planeType ==
"planeEquation")
189 else if (planeType ==
"embeddedPoints")
197 calcPntAndVec(point1, point2, point3);
199 else if (planeType ==
"pointAndNormal")
204 subDict.
found(
"basePoint")
205 ? subDict.
lookup(
"basePoint")
206 : subDict.
lookup(
"point");
209 subDict.
found(
"normalVector")
210 ? subDict.
lookup(
"normalVector")
211 : subDict.
lookup(
"normal");
213 normal_ /=
mag(normal_);
218 <<
"Invalid plane type: " << planeType <<
nl 219 <<
"Valid options include: planeEquation, embeddedPoints and " 231 scalar magUnitVector(
mag(normal_));
233 if (magUnitVector > VSMALL)
235 normal_ /= magUnitVector;
240 <<
"plane normal has zero length. basePoint:" << point_
264 scalar magX =
mag(normal_.
x());
265 scalar magY =
mag(normal_.
y());
266 scalar magZ =
mag(normal_.
z());
273 C[1] = normal_.
y()/normal_.
x();
274 C[2] = normal_.
z()/normal_.
x();
278 C[0] = normal_.
x()/normal_.
z();
279 C[1] = normal_.
y()/normal_.
z();
287 C[0] = normal_.
x()/normal_.
y();
289 C[2] = normal_.
z()/normal_.
y();
293 C[0] = normal_.
x()/normal_.
z();
294 C[1] = normal_.
y()/normal_.
z();
299 C[3] = - C[0] * point_.
x()
309 return p - normal_*((p - point_) & normal_);
315 return mag((p - point_) & normal_);
325 scalar denom =
stabilise((dir & normal_), VSMALL);
327 return ((point_ - pnt0) & normal_)/denom;
351 scalar magX =
mag(dir.
x());
352 scalar magY =
mag(dir.
y());
353 scalar magZ =
mag(dir.
z());
391 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
392 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
410 coeffs1[0],coeffs1[1],coeffs1[2],
411 coeffs2[0],coeffs2[1],coeffs2[2],
412 coeffs3[0],coeffs3[1],coeffs3[2]
415 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
417 return (
inv(a) & (-b));
423 const scalar angle((p - point_) & normal_);
433 if ((
normal() & mirroredPtDir) > 0)
448 os <<
indent <<
"pointAndNormalDict" << nl
461 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].
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.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
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.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
point mirror(const point &p) const
Mirror the supplied point in the plane. Return the mirrored point.
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
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 > &)
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.