From: frohlich Date: Sat, 2 Dec 2006 15:57:55 +0000 (+0000) Subject: Modified Files: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bd3518637cb9477313427745eff4038e0dafedfe;p=simgear.git Modified Files: SGVec2.hxx SGVec3.hxx SGVec4.hxx: Add inf norm function --- diff --git a/simgear/math/SGVec2.hxx b/simgear/math/SGVec2.hxx index 6205e126..31538758 100644 --- a/simgear/math/SGVec2.hxx +++ b/simgear/math/SGVec2.hxx @@ -267,6 +267,13 @@ T norm1(const SGVec2& v) { return fabs(v(0)) + fabs(v(1)); } +/// The inf-norm of the vector +template +inline +T +normI(const SGVec2& v) +{ return SGMisc::max(fabs(v(0)), fabs(v(1))); } + /// The euclidean norm of the vector, that is what most people call length template inline diff --git a/simgear/math/SGVec3.hxx b/simgear/math/SGVec3.hxx index df742744..4d3100b5 100644 --- a/simgear/math/SGVec3.hxx +++ b/simgear/math/SGVec3.hxx @@ -346,6 +346,13 @@ T norm1(const SGVec3& v) { return fabs(v(0)) + fabs(v(1)) + fabs(v(2)); } +/// The inf-norm of the vector +template +inline +T +normI(const SGVec3& v) +{ return SGMisc::max(fabs(v(0)), fabs(v(1)), fabs(v(2))); } + /// Vector cross product template inline diff --git a/simgear/math/SGVec4.hxx b/simgear/math/SGVec4.hxx index b8223a7a..d610a6ca 100644 --- a/simgear/math/SGVec4.hxx +++ b/simgear/math/SGVec4.hxx @@ -314,6 +314,13 @@ T norm1(const SGVec4& v) { return fabs(v(0)) + fabs(v(1)) + fabs(v(2)) + fabs(v(3)); } +/// The inf-norm of the vector +template +inline +T +normI(const SGVec4& v) +{ return SGMisc::max(fabs(v(0)), fabs(v(1)), fabs(v(2)), fabs(v(2))); } + /// The euclidean norm of the vector, that is what most people call length template inline