Commit 582ee21e authored by Andrew Heather's avatar Andrew Heather
Browse files

ENH: plane - updated construct from components to optionally normalise the normal vector

parent 8509fc3c
......@@ -129,23 +129,29 @@ Foam::plane::plane(const vector& normalVector)
}
Foam::plane::plane(const point& basePoint, const vector& normalVector)
Foam::plane::plane
(
const point& basePoint,
const vector& normalVector,
const bool normalise
)
:
unitVector_(normalVector),
basePoint_(basePoint)
{
scalar magUnitVector(mag(unitVector_));
scalar magSqrUnitVector(magSqr(unitVector_));
if (magUnitVector > VSMALL)
{
unitVector_ /= magUnitVector;
}
else
if (magSqrUnitVector < VSMALL)
{
FatalErrorInFunction
<< "plane normal has zero length. basePoint:" << basePoint_
<< abort(FatalError);
}
if (normalise)
{
unitVector_ /= Foam::sqrt(magSqrUnitVector);
}
}
......
......@@ -131,7 +131,12 @@ public:
plane(const vector& normalVector);
//- Construct from normal vector and point in plane
plane(const point& basePoint, const vector& normalVector);
plane
(
const point& basePoint,
const vector& normalVector,
const bool normalise = true
);
//- Construct from three points in plane
plane(const point& point1, const point& point2, const point& point3);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment