31 void Foam::plane::calcPntAndVec(
const scalarList& C)
33 if (
mag(C[0]) > VSMALL)
35 basePoint_ =
vector((-C[3]/C[0]), 0, 0);
39 if (
mag(C[1]) > VSMALL)
41 basePoint_ =
vector(0, (-C[3]/C[1]), 0);
45 if (
mag(C[2]) > VSMALL)
47 basePoint_ =
vector(0, 0, (-C[3]/C[2]));
52 <<
"At least one plane coefficient must have a value" 58 unitVector_ =
vector(C[0], C[1], C[2]);
59 scalar magUnitVector(
mag(unitVector_));
61 if (magUnitVector < VSMALL)
64 <<
"Plane normal defined with zero length" 68 unitVector_ /= magUnitVector;
72 void Foam::plane::calcPntAndVec
79 basePoint_ = (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 unitVector_ = line12 ^ line23;
96 scalar magUnitVector(
mag(unitVector_));
98 if (magUnitVector < VSMALL)
101 <<
"Plane normal defined with zero length" <<
nl 102 <<
"Bad points:" << point1 <<
' ' << point2 <<
' ' << point3
106 unitVector_ /= magUnitVector;
114 unitVector_(normalVector),
117 scalar magUnitVector(
mag(unitVector_));
119 if (magUnitVector > VSMALL)
121 unitVector_ /= magUnitVector;
126 <<
"plane normal has zero length. basePoint:" << basePoint_
134 unitVector_(normalVector),
135 basePoint_(basePoint)
137 scalar magUnitVector(
mag(unitVector_));
139 if (magUnitVector > VSMALL)
141 unitVector_ /= magUnitVector;
146 <<
"plane normal has zero length. basePoint:" << basePoint_
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")
203 basePoint_ = subDict.
lookup(
"basePoint");
204 unitVector_ = subDict.
lookup(
"normalVector");
205 unitVector_ /=
mag(unitVector_);
210 <<
"Invalid plane type: " << planeType <<
nl 211 <<
"Valid options include: planeEquation, embeddedPoints and " 223 scalar magUnitVector(
mag(unitVector_));
225 if (magUnitVector > VSMALL)
227 unitVector_ /= magUnitVector;
232 <<
"plane normal has zero length. basePoint:" << basePoint_
256 scalar magX =
mag(unitVector_.
x());
257 scalar magY =
mag(unitVector_.
y());
258 scalar magZ =
mag(unitVector_.
z());
265 C[1] = unitVector_.
y()/unitVector_.
x();
266 C[2] = unitVector_.
z()/unitVector_.
x();
270 C[0] = unitVector_.
x()/unitVector_.
z();
271 C[1] = unitVector_.
y()/unitVector_.
z();
279 C[0] = unitVector_.
x()/unitVector_.
y();
281 C[2] = unitVector_.
z()/unitVector_.
y();
285 C[0] = unitVector_.
x()/unitVector_.
z();
286 C[1] = unitVector_.
y()/unitVector_.
z();
291 C[3] = - C[0] * basePoint_.
x()
292 - C[1] * basePoint_.
y()
293 - C[2] * basePoint_.
z();
301 return p - unitVector_*((p - basePoint_) & unitVector_);
307 return mag((p - basePoint_) & unitVector_);
317 scalar denom =
stabilise((dir & unitVector_), VSMALL);
319 return ((basePoint_ - pnt0) & unitVector_)/denom;
343 scalar magX =
mag(dir.
x());
344 scalar magY =
mag(dir.
y());
345 scalar magZ =
mag(dir.
z());
383 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
384 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
402 coeffs1[0],coeffs1[1],coeffs1[2],
403 coeffs2[0],coeffs2[1],coeffs2[2],
404 coeffs3[0],coeffs3[1],coeffs3[2]
407 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
409 return (
inv(a) & (-b));
415 const scalar angle((p - basePoint_) & unitVector_);
425 if ((
normal() & mirroredPtDir) > 0)
440 os <<
indent <<
"pointAndNormalDict" << nl
453 if (a.basePoint_ == b.basePoint_ && a.unitVector_ == b.unitVector_)
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.
const point & refPoint() const
Return or return plane base point.
side sideOfPlane(const point &p) const
Return the side of the plane that the point is on.
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
point nearestPoint(const point &p) const
Return nearest point in the plane for the given point.
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 ...
const vector & normal() const
Return plane normal.
plane(const vector &normalVector)
Construct from normal vector through the origin.
point mirror(const point &p) const
Mirror the supplied point in the plane. Return the mirrored point.
ray planeIntersect(const plane &) const
Return the cutting line between this plane and another.
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.
scalar distance(const point &p) const
Return distance from the given point to the plane.
List< scalar > scalarList
A List of scalars.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if succesful.
point planePlaneIntersect(const plane &, const plane &) const
Return the cutting point between this plane and two other planes.
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
scalar normalIntersect(const point &pnt0, const vector &dir) const
Return cut coefficient for plane and line defined by.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
tmp< DimensionedField< scalar, GeoMesh > > stabilise(const DimensionedField< scalar, GeoMesh > &dsf, const dimensioned< scalar > &ds)
vector point
Point is a vector.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
FixedList< scalar, 4 > planeCoeffs() const
Return coefficients for the.
Ostream & operator<<(Ostream &, const ensightPart &)
dimensioned< scalar > mag(const dimensioned< Type > &)
bool operator!=(const particle &, const particle &)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
void writeDict(Ostream &) const
Write to dictionary.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.