VectorSpace: Added normalised function

This is useful for creating const unit vectors
This commit is contained in:
Will Bainbridge
2018-04-18 09:55:02 +01:00
parent ab81dffe4e
commit 32d44d3322

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -428,6 +428,17 @@ inline scalar mag
} }
template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> normalised
(
const VectorSpace<Form, Cmpt, Ncmpts>& vs
)
{
const scalar magVs = mag(vs);
return magVs > 0 ? vs/magVs : Zero;
}
template<class Form, class Cmpt, direction Ncmpts> template<class Form, class Cmpt, direction Ncmpts>
inline VectorSpace<Form, Cmpt, Ncmpts> cmptMultiply inline VectorSpace<Form, Cmpt, Ncmpts> cmptMultiply
( (