35void Foam::plane::makeUnitNormal
37 const char *
const caller,
41 const scalar magNormal(
Foam::mag(normal_));
43 if (magNormal < VSMALL)
46 <<
"Plane normal has zero length.\nCalled from " << caller
57void Foam::plane::calcFromCoeffs
63 const char *
const caller
68 origin_ =
vector((-d/a), 0, 0);
70 else if (
mag(
b) > VSMALL)
74 else if (
mag(c) > VSMALL)
76 origin_ =
vector(0, 0, (-d/c));
81 <<
"At least one plane coefficient must have a value"
86 makeUnitNormal(caller);
90void Foam::plane::calcFromEmbeddedPoints
95 const char *
const caller
98 origin_ = (point1 + point2 + point3)/3;
99 const vector line12 = point1 - point2;
100 const vector line23 = point2 - point3;
105 ||
mag(line23) < VSMALL
106 ||
mag(point3-point1) < VSMALL
110 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
114 normal_ = line12 ^ line23;
116 makeUnitNormal(caller);
124 normal_(normalVector),
133 const point& originPoint,
134 const vector& normalVector,
135 const bool doNormalise
138 normal_(normalVector),
185 if (planeType.empty())
189 origin_ = coeffs.
get<
point>(
"point");
190 normal_ = coeffs.
get<
point>(
"normal");
192 makeUnitNormal(
"point/normal");
194 else if (planeType ==
"pointAndNormal")
198 origin_ = coeffs.
getCompat<
point>(
"point", {{
"basePoint", 1612}});
199 normal_ = coeffs.
getCompat<
point>(
"normal", {{
"normalVector", 1612}});
201 makeUnitNormal(
"point/normal");
203 else if (planeType ==
"planeEquation")
209 subDict.
get<scalar>(
"a"),
210 subDict.
get<scalar>(
"b"),
211 subDict.
get<scalar>(
"c"),
212 subDict.
get<scalar>(
"d"),
216 else if (planeType ==
"embeddedPoints")
220 calcFromEmbeddedPoints
231 <<
"Invalid plane type: " << planeType <<
nl
232 <<
"Valid options: (planeEquation embeddedPoints pointAndNormal)"
253 const scalar magX =
mag(normal_.x());
254 const scalar magY =
mag(normal_.y());
255 const scalar magZ =
mag(normal_.z());
262 coeffs[1] = normal_.y()/normal_.x();
263 coeffs[2] = normal_.z()/normal_.x();
267 coeffs[0] = normal_.x()/normal_.z();
268 coeffs[1] = normal_.y()/normal_.z();
276 coeffs[0] = normal_.x()/normal_.y();
278 coeffs[2] = normal_.z()/normal_.y();
282 coeffs[0] = normal_.x()/normal_.z();
283 coeffs[1] = normal_.y()/normal_.z();
290 - coeffs[0] * origin_.x()
291 - coeffs[1] * origin_.y()
292 - coeffs[2] * origin_.z()
305 const scalar denom =
stabilise((dir & normal_), VSMALL);
307 return ((origin_ - pnt0) & normal_)/denom;
318 const vector& n1 = this->normal();
321 const point& p1 = this->origin();
324 const scalar n1p1 = n1 & p1;
325 const scalar n2p2 = n2 & p2;
327 const vector dir = n1 ^ n2;
331 const scalar magX =
mag(dir.
x());
332 const scalar magY =
mag(dir.
y());
333 const scalar magZ =
mag(dir.
z());
372 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
373 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
391 coeffs1[0],coeffs1[1],coeffs1[2],
392 coeffs2[0],coeffs2[1],coeffs2[2],
393 coeffs3[0],coeffs3[1],coeffs3[2]
396 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
398 return (
inv(a) & (-
b));
414 p[0] = -1.0*(coeff[1]*
p[1] + coeff[2]*
p[2] + coeff[3])/coeff[0];
418 p[1] = -1.0*(coeff[0]*
p[0] + coeff[2]*
p[2] + coeff[3])/coeff[1];
423 p[2] = -1.0*(coeff[0]*
p[0] + coeff[1]*
p[1] + coeff[3])/coeff[2];
432 const vector mirroredPtDir =
p - nearestPoint(
p);
434 if ((normal() & mirroredPtDir) > 0)
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)....
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
virtual Ostream & endBlock()
Write end block group.
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
const Cmpt & z() const
Access to the vector z component.
const Cmpt & y() const
Access to the vector y component.
const Cmpt & x() const
Access to the vector x component.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Foam::dictionary writeDict() const
Write to dictionary.
A reference point and direction.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
plane()
Construct zero-initialised.
point mirror(const point &p) const
Mirror the supplied point in the plane. Return the mirrored point.
FixedList< scalar, 4 > planeCoeffs() const
const point & origin() const noexcept
The plane base point.
scalar normalIntersect(const point &pnt0, const vector &dir) const
point planePlaneIntersect(const plane &plane2, const plane &plane3) const
Return the cutting point between this plane and two other planes.
ray planeIntersect(const plane &plane2) const
Return the cutting line between this plane and another.
const vector & normal() const noexcept
The plane unit normal.
point somePointInPlane(const scalar dist=1e-3) const
Return a point somewhere on the plane, a distance from the base.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
scalar distance(const vector &p1, const vector &p2)
vector point
Point is a vector.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
dimensionedScalar stabilise(const dimensionedScalar &x, const dimensionedScalar &y)
static constexpr const zero Zero
Global zero (0)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
constexpr char nl
The newline '\n' character (0x0a)