2
0

IcePlane.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. // Precompiled Header
  19. #include "Stdafx.h"
  20. using namespace IceMaths;
  21. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  22. /**
  23. * Computes the plane equation from 3 points.
  24. * \param p0 [in] first point
  25. * \param p1 [in] second point
  26. * \param p2 [in] third point
  27. * \return Self-reference
  28. */
  29. ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  30. Plane& Plane::Set(const Point& p0, const Point& p1, const Point& p2)
  31. {
  32. Point Edge0 = p1 - p0;
  33. Point Edge1 = p2 - p0;
  34. n = Edge0 ^ Edge1;
  35. n.Normalize();
  36. d = -(p0 | n);
  37. return *this;
  38. }