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")
191 {
"point",
"basePoint"}
198 {
"normal",
"normalVector"}
205 <<
"Invalid plane type: " << planeType <<
nl 206 <<
"Valid options include: planeEquation, embeddedPoints and " 218 scalar magUnitVector(
mag(normal_));
220 if (magUnitVector > vSmall)
222 normal_ /= magUnitVector;
227 <<
"plane normal has zero length. basePoint:" << point_
251 scalar magX =
mag(normal_.
x());
252 scalar magY =
mag(normal_.
y());
253 scalar magZ =
mag(normal_.
z());
260 C[1] = normal_.
y()/normal_.
x();
261 C[2] = normal_.
z()/normal_.
x();
265 C[0] = normal_.
x()/normal_.
z();
266 C[1] = normal_.
y()/normal_.
z();
274 C[0] = normal_.
x()/normal_.
y();
276 C[2] = normal_.
z()/normal_.
y();
280 C[0] = normal_.
x()/normal_.
z();
281 C[1] = normal_.
y()/normal_.
z();
286 C[3] = - C[0] * point_.
x()
302 const scalar perturbX = refPt.
x() + 1
e-3;
303 const scalar perturbY = refPt.
y() + 1
e-3;
304 const scalar perturbZ = refPt.
z() + 1
e-3;
306 if (
mag(planeCoeffs[2]) < small)
308 if (
mag(planeCoeffs[1]) < small)
314 + planeCoeffs[1]*perturbY
315 + planeCoeffs[2]*perturbZ
330 + planeCoeffs[0]*perturbX
331 + planeCoeffs[2]*perturbZ
347 + planeCoeffs[0]*perturbX
348 + planeCoeffs[1]*perturbY
363 return p - normal_*((p - point_) & normal_);
369 return mag((p - point_) & normal_);
379 const scalar num = (point_ - pnt0) & normal_;
380 const scalar den = dir & normal_;
382 return mag(den) >
mag(num)*vSmall ? num/den : vGreat;
406 scalar magX =
mag(dir.
x());
407 scalar magY =
mag(dir.
y());
408 scalar magZ =
mag(dir.
z());
446 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
447 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
465 coeffs1[0],coeffs1[1],coeffs1[2],
466 coeffs2[0],coeffs2[1],coeffs2[2],
467 coeffs3[0],coeffs3[1],coeffs3[2]
470 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
472 return (
inv(a) & (-b));
478 const scalar angle((p - point_) & normal_);
488 if ((
normal() & mirroredPtDir) > 0)
501 writeEntry(os,
"planeType",
"pointAndNormal");
502 os <<
indent <<
"pointAndNormalDict" <<
nl 514 if (a.point_ == b.point_ && a.normal_ == b.normal_)
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)...
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
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.
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.
Form normalised(const VectorSpace< Form, Cmpt, Ncmpts > &vs)
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
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 & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.