Plane.cpp 340 B

12345678910111213141516
  1. #include "client/math/Plane.h"
  2. Plane::Plane() : d(0) {
  3. }
  4. void Plane::set(const Vector3& va, const Vector3& vb, const Vector3& vc) {
  5. Vector3 h1 = vb - va;
  6. Vector3 h2 = vc - va;
  7. abc = h1.cross(h2);
  8. abc.normalize();
  9. d = -h1.dot(va);
  10. }
  11. float Plane::getSignedDistance(const Vector3& v) const {
  12. return abc.dot(v) + d;
  13. }