gescl3d.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. //////////////////////////////////////////////////////////////////////////////
  3. //
  4. // Copyright 2015 Autodesk, Inc. All rights reserved.
  5. //
  6. // Use of this software is subject to the terms of the Autodesk license
  7. // agreement provided at the time of installation or download, or which
  8. // otherwise accompanies this software in either electronic or hard copy form.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //
  12. // DESCRIPTION:
  13. //
  14. // This file contains the class AcGeScale3d - a mathematical entity used to
  15. // represents scaling transformations in 3-space.
  16. // Contract: The scale vector components must never be set to zero
  17. // (or near zero within floating point tolerances).
  18. #ifndef AC_GESCL3D_H
  19. #define AC_GESCL3D_H
  20. #include "adesk.h"
  21. #include "gegbl.h"
  22. #pragma pack (push, 8)
  23. class AcGeMatrix3d;
  24. class
  25. GE_DLLEXPIMPORT
  26. AcGeScale3d
  27. {
  28. public:
  29. AcGeScale3d();
  30. AcGeScale3d(const AcGeScale3d& src);
  31. AcGeScale3d(double factor);
  32. AcGeScale3d(double xFact, double yFact, double zFact);
  33. // The identity scaling operation.
  34. //
  35. static const AcGeScale3d kIdentity;
  36. // Multiplication.
  37. //
  38. AcGeScale3d operator * (const AcGeScale3d& sclVec) const;
  39. AcGeScale3d& operator *= (const AcGeScale3d& scl);
  40. AcGeScale3d& preMultBy (const AcGeScale3d& leftSide);
  41. AcGeScale3d& postMultBy (const AcGeScale3d& rightSide);
  42. AcGeScale3d& setToProduct(const AcGeScale3d& sclVec1, const AcGeScale3d& sclVec2);
  43. AcGeScale3d operator * (double s) const;
  44. AcGeScale3d& operator *= (double s);
  45. AcGeScale3d& setToProduct(const AcGeScale3d& sclVec, double s);
  46. friend
  47. GE_DLLEXPIMPORT
  48. AcGeScale3d operator * (double, const AcGeScale3d& scl);
  49. // Multiplicative inverse.
  50. //
  51. AcGeScale3d inverse () const;
  52. AcGeScale3d& invert ();
  53. Adesk::Boolean isProportional(const AcGeTol& tol = AcGeContext::gTol) const;
  54. // Tests for equivalence using the infinity norm.
  55. //
  56. bool operator == (const AcGeScale3d& sclVec) const;
  57. bool operator != (const AcGeScale3d& sclVec) const;
  58. bool isEqualTo (const AcGeScale3d& scaleVec,
  59. const AcGeTol& tol = AcGeContext::gTol) const;
  60. // For convenient access to the data.
  61. //
  62. double operator [] (unsigned int i) const;
  63. double& operator [] (unsigned int i);
  64. AcGeScale3d& set (double sc0, double sc1, double sc2);
  65. // Conversion to/from matrix form.
  66. //
  67. operator AcGeMatrix3d () const;
  68. void getMatrix(AcGeMatrix3d& mat) const;
  69. AcGeScale3d& extractScale ( const AcGeMatrix3d& mat );
  70. AcGeScale3d& removeScale ( AcGeMatrix3d& mat );
  71. // The scale components in x, y and z.
  72. //
  73. double sx, sy, sz;
  74. };
  75. inline bool
  76. AcGeScale3d::operator == (const AcGeScale3d& s) const
  77. {
  78. return this->isEqualTo(s);
  79. }
  80. // This operator is the logical negation of the `==' operator.
  81. //
  82. inline bool
  83. AcGeScale3d::operator != (const AcGeScale3d& s) const
  84. {
  85. return !(this->isEqualTo(s));
  86. }
  87. // Indexes the scale vector as if it were an array. `sx' is index `0',
  88. // `sy' is index `1' and `sz' is index `2'.
  89. //
  90. inline double
  91. AcGeScale3d::operator [] (unsigned int i) const
  92. {
  93. return *(&sx+i);
  94. }
  95. inline double&
  96. AcGeScale3d::operator [] (unsigned int i)
  97. {
  98. return *(&sx+i);
  99. }
  100. #pragma pack (pop)
  101. #endif