mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: plane - updated construct from components to optionally normalise the normal vector
This commit is contained in:
@ -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),
|
unitVector_(normalVector),
|
||||||
basePoint_(basePoint)
|
basePoint_(basePoint)
|
||||||
{
|
{
|
||||||
scalar magUnitVector(mag(unitVector_));
|
scalar magSqrUnitVector(magSqr(unitVector_));
|
||||||
|
|
||||||
if (magUnitVector > VSMALL)
|
if (magSqrUnitVector < VSMALL)
|
||||||
{
|
|
||||||
unitVector_ /= magUnitVector;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "plane normal has zero length. basePoint:" << basePoint_
|
<< "plane normal has zero length. basePoint:" << basePoint_
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (normalise)
|
||||||
|
{
|
||||||
|
unitVector_ /= Foam::sqrt(magSqrUnitVector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,12 @@ public:
|
|||||||
plane(const vector& normalVector);
|
plane(const vector& normalVector);
|
||||||
|
|
||||||
//- Construct from normal vector and point in plane
|
//- 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
|
//- Construct from three points in plane
|
||||||
plane(const point& point1, const point& point2, const point& point3);
|
plane(const point& point1, const point& point2, const point& point3);
|
||||||
|
|||||||
Reference in New Issue
Block a user