Plane3D.cpp 489 B

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