quadTransforms.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. //-----------------------------------------------------------------------------
  2. // Copyright (c) 2012 GarageGames, LLC
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to
  6. // deal in the Software without restriction, including without limitation the
  7. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  8. // sell copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
  20. // IN THE SOFTWARE.
  21. //-----------------------------------------------------------------------------
  22. #ifndef _QUADTOQUADTRANSFORMS_H_
  23. #define _QUADTOQUADTRANSFORMS_H_
  24. #ifndef _MPOINT2_H_
  25. #include "math/mPoint2.h"
  26. #endif
  27. #ifndef _MPOINT3_H_
  28. #include "math/mPoint3.h"
  29. #endif
  30. #ifndef _MMATRIX_H_
  31. #include "math/mMatrix.h"
  32. #endif
  33. // NOTE: The code in these classes originate from the Wild Magic Source Code
  34. // library by David Eberly and is used with permission.
  35. /// This class does bilinear mapping of quadrilateral to a square.
  36. class BiQuadToSqr
  37. {
  38. public:
  39. /// Constructs the transform class from the quadrilateral
  40. /// points in counter clockwise order.
  41. BiQuadToSqr( const Point2F &p00,
  42. const Point2F &p10,
  43. const Point2F &p11,
  44. const Point2F &p01 );
  45. /// Transforms the point.
  46. Point2F transform( const Point2F &p ) const;
  47. protected:
  48. static F32 deviation( const Point2F &sp );
  49. Point2F m_kP00, m_kB, m_kC, m_kD;
  50. F32 m_fBC, m_fBD, m_fCD;
  51. };
  52. class BiSqrToQuad3D
  53. {
  54. public:
  55. BiSqrToQuad3D( const Point3F &pnt00,
  56. const Point3F &pnt10,
  57. const Point3F &pnt11,
  58. const Point3F &pnt01 );
  59. Point3F transform( const Point2F &pnt ) const;
  60. protected:
  61. Point3F p00, p01, p10, p11;
  62. };
  63. #endif // _QUADTOQUADTRANSFORMS_H_