Vector3d.h
Upload User: hcfgz168
Upload Date: 2011-09-11
Package Size: 116k
Code Size: 2k
Category:

OpenGL program

Development Platform:

WINDOWS

  1. //********************************************
  2. // Vector3d.h
  3. //********************************************
  4. // pierre.alliez@cnet.francetelecom.fr
  5. // Created : 10/12/97
  6. // Modified : 19/01/98
  7. //********************************************
  8. #ifndef _VECTOR_3D_
  9. #define _VECTOR_3D_
  10. #include "Object3d.h"
  11. class CVertex3d;
  12. class CVector3d : public CObject3d
  13. {
  14. private :
  15. // Geometry
  16. float m_x;
  17. float m_y;
  18. float m_z;
  19. public :
  20. CVector3d() { m_x = m_y = m_z = 0.0f; } 
  21. virtual ~CVector3d();
  22. // Constructors
  23. CVector3d(const float x,const float y,const float z);
  24. CVector3d(CVector3d &vector);
  25. CVector3d(CVector3d *pVector);
  26. CVector3d(CVertex3d *pVertex1,CVertex3d *pVertex2);
  27. CVector3d(CVertex3d &vertex1,CVertex3d &vertex2);
  28. // Debug
  29. void Trace();
  30. // Data setting
  31. virtual int GetType();
  32. void Clear(void);
  33. void Set(CVector3d *pVector);
  34. void Set(CVector3d &vector);
  35. void Set(CVertex3d *pVertex1,CVertex3d *pVertex2);
  36. void Set(const float x,const float y,const float z);
  37. void Copy(CVector3d &vector);
  38. void Copy(CVector3d *pVector);
  39. // Per coordinate (explicit inline functions)
  40. void x(float x) { m_x = x; }
  41. void y(float y) { m_y = y; }
  42. void z(float z) { m_z = z; } 
  43. // Data access (explicit inline functions)
  44. float x(void) { return m_x; }
  45. float y(void) { return m_y; }
  46. float z(void) { return m_z; }
  47. // Operators
  48. CVector3d operator=(CVector3d& vector); // Setting
  49. void operator+=(CVector3d* pVector);
  50. void operator/=(float factor);
  51. void operator*=(float factor);
  52. void Inner(CVector3d& vector);
  53. static CVector3d Inner(CVector3d* u,CVector3d* v); // Stupid c++
  54. // Misc
  55. void NormalizeL2(void);
  56. void NormalizeL2(float value);
  57. double GetNormL2(void);
  58. double GetNormL2Square(void);
  59. int Collinear(CVector3d *pVector);
  60. int Collinear(CVector3d &vector);
  61. void RotateXZ(float alpha);
  62. };
  63. // External operators
  64. CVector3d operator+(CVector3d& u,CVector3d& v); // Add
  65. CVector3d operator-(CVector3d& u,CVector3d& v); // Subtract
  66. CVector3d operator^(CVector3d& u,CVector3d& v); // Inner
  67. #endif // _VECTOR_3D_