Go to the documentation of this file.
34 void Foam::plane::makeUnitNormal
36 const char *
const caller,
40 const scalar magNormal(
Foam::mag(normal_));
42 if (magNormal < VSMALL)
45 <<
"Plane normal has zero length.\nCalled from " << caller
56 void Foam::plane::calcFromCoeffs
62 const char *
const caller
67 origin_ =
vector((-d/a), 0, 0);
69 else if (
mag(
b) > VSMALL)
73 else if (
mag(
c) > VSMALL)
80 <<
"At least one plane coefficient must have a value"
85 makeUnitNormal(caller);
89 void Foam::plane::calcFromEmbeddedPoints
94 const char *
const caller
97 origin_ = (point1 + point2 + point3)/3;
98 const vector line12 = point1 - point2;
99 const vector line23 = point2 - point3;
104 ||
mag(line23) < VSMALL
105 ||
mag(point3-point1) < VSMALL
109 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
113 normal_ = line12 ^ line23;
115 makeUnitNormal(caller);
123 normal_(normalVector),
132 const point& originPoint,
133 const vector& normalVector,
134 const bool doNormalise
137 normal_(normalVector),
183 if (planeType ==
"planeEquation")
189 subDict.
get<scalar>(
"a"),
190 subDict.
get<scalar>(
"b"),
191 subDict.
get<scalar>(
"c"),
192 subDict.
get<scalar>(
"d"),
196 else if (planeType ==
"embeddedPoints")
198 const dictionary& subDict =
dict.subDict(
"embeddedPointsDict");
200 calcFromEmbeddedPoints
202 subDict.get<
point>(
"point1"),
203 subDict.get<
point>(
"point2"),
204 subDict.get<
point>(
"point3"),
209 else if (planeType ==
"pointAndNormal")
211 const dictionary& subDict =
dict.subDict(
"pointAndNormalDict");
213 origin_ = subDict.getCompat<
point>(
"point", {{
"basePoint", 1612}});
214 normal_ = subDict.getCompat<
point>(
"normal", {{
"normalVector", 1612}});
216 makeUnitNormal(
"pointAndNormalDict");
221 <<
"Invalid plane type: " << planeType <<
nl
222 <<
"Valid options: (planeEquation embeddedPoints pointAndNormal)"
243 const scalar magX =
mag(normal_.x());
244 const scalar magY =
mag(normal_.y());
245 const scalar magZ =
mag(normal_.z());
252 coeffs[1] = normal_.y()/normal_.x();
253 coeffs[2] = normal_.z()/normal_.x();
257 coeffs[0] = normal_.x()/normal_.z();
258 coeffs[1] = normal_.y()/normal_.z();
266 coeffs[0] = normal_.x()/normal_.y();
268 coeffs[2] = normal_.z()/normal_.y();
272 coeffs[0] = normal_.x()/normal_.z();
273 coeffs[1] = normal_.y()/normal_.z();
280 - coeffs[0] * origin_.x()
281 - coeffs[1] * origin_.y()
282 - coeffs[2] * origin_.z()
295 const scalar denom =
stabilise((dir & normal_), VSMALL);
297 return ((origin_ - pnt0) & normal_)/denom;
308 const vector& n1 = this->normal();
311 const point& p1 = this->origin();
314 const scalar n1p1 = n1 & p1;
315 const scalar n2p2 = n2 & p2;
317 const vector dir = n1 ^ n2;
321 const scalar magX =
mag(dir.
x());
322 const scalar magY =
mag(dir.
y());
323 const scalar magZ =
mag(dir.
z());
362 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
363 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
381 coeffs1[0],coeffs1[1],coeffs1[2],
382 coeffs2[0],coeffs2[1],coeffs2[2],
383 coeffs3[0],coeffs3[1],coeffs3[2]
386 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
388 return (
inv(a) & (-
b));
404 p[0] = -1.0*(coeff[1]*
p[1] + coeff[2]*
p[2] + coeff[3])/coeff[0];
408 p[1] = -1.0*(coeff[0]*
p[0] + coeff[2]*
p[2] + coeff[3])/coeff[1];
413 p[2] = -1.0*(coeff[0]*
p[0] + coeff[1]*
p[1] + coeff[3])/coeff[2];
422 const vector mirroredPtDir =
p - nearestPoint(
p);
424 if ((normal() & mirroredPtDir) > 0)
point planePlaneIntersect(const plane &plane2, const plane &plane3) const
A templated (3 x 3) tensor of objects of <T> derived from MatrixSpace.
const vector & normal() const
void writeDict(Ostream &os) const
A class for handling words, derived from Foam::string.
static Form uniform(const Cmpt &s)
static constexpr const zero Zero
const point & origin() const
virtual Ostream & beginBlock(const keyType &kw)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option=keyType::REGEX) const
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Ostream & operator<<(Ostream &, const boundaryPatch &p)
const dimensionedScalar b
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
FixedList< scalar, 4 > planeCoeffs() const
virtual Ostream & endBlock()
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
OBJstream os(runTime.globalPath()/outputName)
errorManip< error > abort(error &err)
Vector< scalar > vector
A scalar version of the templated Vector.
scalar distance(const vector &p1, const vector &p2)
#define FatalErrorInFunction
ray planeIntersect(const plane &plane2) const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A 1D vector of objects of type <T> with a fixed length <N>.
Ostream & writeEntry(const keyType &key, const T &value)
const dimensionedScalar c
#define FatalIOErrorInFunction(ios)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
vector point
Point is a vector.
scalar normalIntersect(const point &pnt0, const vector &dir) const
point somePointInPlane(const scalar dist=1e-3) const
point mirror(const point &p) const