X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fmath%2FSGTriangle.hxx;h=af6f32f14b8404145465e5bc58e53a34f8aac333;hb=578af00b0d48100c540154f54293a1b77a0655fe;hp=2cba610a582648903fbd0142892af02df85c5f78;hpb=4a4e8c87b8f5b224350d9407d529f8cfe8e68553;p=simgear.git diff --git a/simgear/math/SGTriangle.hxx b/simgear/math/SGTriangle.hxx index 2cba610a..af6f32f1 100644 --- a/simgear/math/SGTriangle.hxx +++ b/simgear/math/SGTriangle.hxx @@ -42,13 +42,7 @@ public: } SGVec3 getCenter() const - { - SGBox box; - box.expandBy(_v0); - box.expandBy(_v0 + _d[0]); - box.expandBy(_v0 + _d[1]); - return box.getCenter(); - } + { 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