32 void Foam::plane::calcPntAndVec(
const scalarList& C)
34 if (
mag(C[0]) > VSMALL)
36 basePoint_ =
vector((-C[3]/C[0]), 0, 0);
40 if (
mag(C[1]) > VSMALL)
42 basePoint_ =
vector(0, (-C[3]/C[1]), 0);
46 if (
mag(C[2]) > VSMALL)
48 basePoint_ =
vector(0, 0, (-C[3]/C[2]));
52 FatalErrorIn(
"void plane::calcPntAndVec(const scalarList&)")
53 <<
"At least one plane coefficient must have a value"
59 unitVector_ =
vector(C[0], C[1], C[2]);
60 scalar magUnitVector(
mag(unitVector_));
62 if (magUnitVector < VSMALL)
64 FatalErrorIn(
"void plane::calcPntAndVec(const scalarList&)")
65 <<
"Plane normal defined with zero length"
69 unitVector_ /= magUnitVector;
73 void Foam::plane::calcPntAndVec
80 basePoint_ = (point1 + point2 + point3)/3;
81 vector line12 = point1 - point2;
82 vector line23 = point2 - point3;
87 ||
mag(line23) < VSMALL
88 ||
mag(point3-point1) < VSMALL
93 "void plane::calcPntAndVec\n"
102 unitVector_ = line12 ^ line23;
103 scalar magUnitVector(
mag(unitVector_));
105 if (magUnitVector < VSMALL)
109 "void plane::calcPntAndVec\n"
115 ) <<
"Plane normal defined with zero length"
119 unitVector_ /= magUnitVector;
128 unitVector_(normalVector),
136 unitVector_(normalVector),
137 basePoint_(basePoint)
139 scalar magUnitVector(
mag(unitVector_));
141 if (magUnitVector > VSMALL)
143 unitVector_ /= magUnitVector;
147 FatalErrorIn(
"plane::plane(const point&, const vector&)")
148 <<
"plane normal has zero length"
169 calcPntAndVec(a, b, c);
181 if (planeType ==
"planeEquation")
194 else if (planeType ==
"embeddedPoints")
202 calcPntAndVec(point1, point2, point3);
204 else if (planeType ==
"pointAndNormal")
208 basePoint_ = subDict.
lookup(
"basePoint");
209 unitVector_ = subDict.
lookup(
"normalVector");
210 unitVector_ /=
mag(unitVector_);
216 "plane::plane(const dictionary&)",
219 <<
"Invalid plane type: " << planeType
231 scalar magUnitVector(
mag(unitVector_));
233 if (magUnitVector > VSMALL)
235 unitVector_ /= magUnitVector;
240 <<
"plane normal has zero length"
267 scalar magX =
mag(unitVector_.x());
268 scalar magY =
mag(unitVector_.y());
269 scalar magZ =
mag(unitVector_.z());
276 C[1] = unitVector_.y()/unitVector_.x();
277 C[2] = unitVector_.z()/unitVector_.x();
281 C[0] = unitVector_.x()/unitVector_.z();
282 C[1] = unitVector_.y()/unitVector_.z();
290 C[0] = unitVector_.x()/unitVector_.y();
292 C[2] = unitVector_.z()/unitVector_.y();
296 C[0] = unitVector_.x()/unitVector_.z();
297 C[1] = unitVector_.y()/unitVector_.z();
302 C[3] = - C[0] * basePoint_.x()
303 - C[1] * basePoint_.y()
304 - C[2] * basePoint_.z();
313 return p - unitVector_*((p - basePoint_) & unitVector_);
320 return mag((p - basePoint_) & unitVector_);
331 scalar denom =
stabilise((dir & unitVector_), VSMALL);
333 return ((basePoint_ - pnt0) & unitVector_)/denom;
348 const point& p1 = refPoint();
358 scalar magX =
mag(dir.
x());
359 scalar magY =
mag(dir.
y());
360 scalar magZ =
mag(dir.
z());
398 pt[i1] = (n2[i2]*n1p1 - n1[i2]*n2p2) / (n1[i1]*n2[i2] - n2[i1]*n1[i2]);
399 pt[i2] = (n2[i1]*n1p1 - n1[i1]*n2p2) / (n1[i2]*n2[i1] - n1[i1]*n2[i2]);
418 coeffs1[0],coeffs1[1],coeffs1[2],
419 coeffs2[0],coeffs2[1],coeffs2[2],
420 coeffs3[0],coeffs3[1],coeffs3[2]
423 vector b(coeffs1[3],coeffs2[3],coeffs3[3]);
425 return (
inv(a) & (-b));
433 os <<
indent <<
"pointAndNormalDict" << nl
446 if (a.basePoint_ == b.basePoint_ && a.unitVector_ == b.unitVector_)