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

This commit is contained in:
Andrew Heather
2016-08-11 12:14:34 +01:00
parent 8509fc3ce4
commit 582ee21ef0
2 changed files with 19 additions and 8 deletions

View File

@ -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);
}
}

View File

@ -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);