]> git.mxchange.org Git - simgear.git/blobdiff - simgear/math/SGTriangle.hxx
Allow geocentric distance computations to return radians.
[simgear.git] / simgear / math / SGTriangle.hxx
index 2cba610a582648903fbd0142892af02df85c5f78..af6f32f14b8404145465e5bc58e53a34f8aac333 100644 (file)
@@ -42,13 +42,7 @@ public:
   }
 
   SGVec3<T> getCenter() const
-  {
-    SGBox<T> 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<T> getVertex(unsigned i) const
@@ -77,6 +71,16 @@ public:
     _d[0] = _d[1];
     _d[1] = tmp;
   }
+
+  SGTriangle<T> transform(const SGMatrix<T>& matrix) const
+  {
+    SGTriangle<T> 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