From: frohlich Date: Fri, 8 Dec 2006 12:17:30 +0000 (+0000) Subject: Modified Files: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=67d837c4ec71e21c9d52914344b4dafb7fc06b45;p=simgear.git Modified Files: SGVec3.hxx: Generate any perpandicular vector to a given one. --- diff --git a/simgear/math/SGVec3.hxx b/simgear/math/SGVec3.hxx index 4d3100b5..d9d998df 100644 --- a/simgear/math/SGVec3.hxx +++ b/simgear/math/SGVec3.hxx @@ -364,6 +364,20 @@ cross(const SGVec3& v1, const SGVec3& v2) v1(0)*v2(1) - v1(1)*v2(0)); } +/// return any vector perpandicular to v +template +inline +SGVec3 +perpandicular(const SGVec3& v) +{ + if (fabs(v.x()) < fabs(v.y()) && fabs(v.x()) < fabs(v.z())) + return cross(SGVec3f(1, 0, 0), v); + else if (fabs(v.y()) < fabs(v.x()) && fabs(v.y()) < fabs(v.z())) + return cross(SGVec3f(0, 1, 0), v); + else + return cross(SGVec3f(0, 0, 1), v); +} + /// The euclidean norm of the vector, that is what most people call length template inline