Vector.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Copyright (c) 2009 Brandon Jones
  3. //
  4. // This software is provided 'as-is', without any express or implied
  5. // warranty. In no event will the authors be held liable for any damages
  6. // arising from the use of this software.
  7. //
  8. // Permission is granted to anyone to use this software for any purpose,
  9. // including commercial applications, and to alter it and redistribute it
  10. // freely, subject to the following restrictions:
  11. //
  12. // 1. The origin of this software must not be misrepresented; you must not
  13. // claim that you wrote the original software. If you use this software
  14. // in a product, an acknowledgment in the product documentation would be
  15. // appreciated but is not required.
  16. //
  17. // 2. Altered source versions must be plainly marked as such, and must not be
  18. // misrepresented as being the original software.
  19. //
  20. // 3. This notice may not be removed or altered from any source
  21. // distribution.
  22. //
  23. #if !defined(SQRAT_TEST_VECTOR_H)
  24. #define SQRAT_TEST_VECTOR_H
  25. #include <sqrat.h>
  26. namespace Sqrat {
  27. // A simple Vector class used to demonstrate binding
  28. class Vec2 {
  29. public:
  30. float x, y;
  31. Vec2( void );
  32. Vec2( const Vec2 &v );
  33. Vec2( const float vx, const float vy );
  34. bool operator ==( const Vec2 &v ) const;
  35. Vec2 operator -( void ) const;
  36. Vec2 operator +( const Vec2& v ) const;
  37. Vec2 operator -( const Vec2& v ) const;
  38. Vec2 operator *( const float f ) const;
  39. Vec2 operator /( const float f ) const;
  40. Vec2& operator =( const Vec2& v );
  41. float Length( void ) const;
  42. float Distance( const Vec2 &v ) const;
  43. Vec2& Normalize( void );
  44. float Dot( const Vec2 &v ) const;
  45. };
  46. }
  47. #endif