Plane.cpp 450 B

12345678910111213141516171819202122232425
  1. #include "client/math/Plane.h"
  2. Plane::Plane() : a(0), b(0), c(0), d(0)
  3. {
  4. }
  5. void Plane::set(const Vector& va, const Vector& vb, const Vector& vc)
  6. {
  7. Vector h1 = vb;
  8. h1.sub(va);
  9. Vector h2 = vc;
  10. h2.sub(va);
  11. h1.cross(h2);
  12. h1.normalize();
  13. a = h1.getX();
  14. b = h1.getY();
  15. c = h1.getZ();
  16. d = -h1.dot(va);
  17. }
  18. float Plane::getSignedDistance(float x, float y, float z) const
  19. {
  20. return x * a + y * b + z * c + d;
  21. }