Plane.cpp 526 B

123456789101112131415161718192021
  1. #include "core/math/Plane.hpp"
  2. Core::Plane::Plane() : abc(), d(0) {
  3. }
  4. Core::Plane::Plane(const Vector3& a, const Vector3& b, const Vector3& c)
  5. : abc((b - a).cross(c - a).normalize()), d(-abc.dot(b)) {
  6. }
  7. float Core::Plane::getSignedDistance(const Vector3& v) const {
  8. return abc.dot(v) + d;
  9. }
  10. void Core::Plane::toString(BufferString& s) const {
  11. s.append("(");
  12. s.append(abc[0]).append(" x + ");
  13. s.append(abc[1]).append(" y + ");
  14. s.append(abc[2]).append(" z + ");
  15. s.append(d);
  16. s.append(')');
  17. }