2
0

IcePlane.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  2. /**
  3. * Contains code for planes.
  4. * \file IcePlane.cpp
  5. * \author Pierre Terdiman
  6. * \date April, 4, 2000
  7. */
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  9. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  10. /**
  11. * Plane class.
  12. * \class Plane
  13. * \author Pierre Terdiman
  14. * \version 1.0
  15. */
  16. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  17. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  18. #include "../Opcode.h"
  19. using namespace IceMaths;
  20. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  21. /**
  22. * Computes the plane equation from 3 points.
  23. * \param p0 [in] first point
  24. * \param p1 [in] second point
  25. * \param p2 [in] third point
  26. * \return Self-reference
  27. */
  28. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  29. Plane& Plane::Set(const Point& p0, const Point& p1, const Point& p2)
  30. {
  31. Point Edge0 = p1 - p0;
  32. Point Edge1 = p2 - p0;
  33. n = Edge0 ^ Edge1;
  34. n.Normalize();
  35. d = -(p0 | n);
  36. return *this;
  37. }