X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGTriangle.hxx;h=af6f32f14b8404145465e5bc58e53a34f8aac333;hb=ce54997be569ebcac4222321e7ae3fecccd01324;hp=888102cf5d8026bb86d2954af66eb13af0d727b5;hpb=de020ee69524393daf11200aa0a46bfd5aa2409a;p=simgear.git diff --git a/simgear/math/SGTriangle.hxx b/simgear/math/SGTriangle.hxx index 888102cf..af6f32f1 100644 --- a/simgear/math/SGTriangle.hxx +++ b/simgear/math/SGTriangle.hxx @@ -41,14 +41,8 @@ public: _d[1] = v[2] - v[0]; } - SGVec3d getCenter() const - { - SGBoxd box; - box.expandBy(_v0); - box.expandBy(_v0 + _d[0]); - box.expandBy(_v0 + _d[1]); - return box.getCenter(); - } + SGVec3 getCenter() const + { return _v0 + T(1)/T(3)*(_d[0] + _d[1]); } // note that the index is unchecked SGVec3 getVertex(unsigned i) const @@ -77,6 +71,16 @@ public: _d[0] = _d[1]; _d[1] = tmp; } + + SGTriangle transform(const SGMatrix& matrix) const + { + SGTriangle triangle; + triangle._v0 = matrix.xformPt(_v0); + triangle._d[0] = matrix.xformVec(_d[0]); + triangle._d[1] = matrix.xformVec(_d[1]); + return triangle; + } + private: /// Store one vertex directly, _d is the offset of the other two /// vertices wrt the base vertex