Vec2f.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2014, Ceetron AS
8 // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Ceetron AS. The contents of this file may
9 // not be disclosed to third parties, copied or duplicated in any form, in whole or in part,
10 // without the prior written permission of Ceetron AS.
11 //##################################################################################################
12 
13 #pragma once
14 
15 #include "CeeCore/Base.h"
16 
17 namespace cee {
18 
19 //==================================================================================================
20 //
21 // 2D float vector
22 //
23 //==================================================================================================
24 class CEE_CORE_EXPORT Vec2f
25 {
26 public:
27  Vec2f();
28  Vec2f(const Vec2f& other);
29  Vec2f(float x, float y);
30 
31  Vec2f& operator=(const Vec2f& other);
32  bool operator==(const Vec2f& rhs) const;
33  bool operator!=(const Vec2f& rhs) const;
34  const Vec2f operator+(const Vec2f& rhs) const;
35  const Vec2f operator-(const Vec2f& rhs) const;
36  const Vec2f operator*(float scalar) const;
37  const Vec2f operator/(float scalar) const;
38  Vec2f& operator+=(const Vec2f& rhs);
39  Vec2f& operator-=(const Vec2f& rhs);
40  Vec2f& operator*=(float scalar);
41  Vec2f& operator/=(float scalar);
42 
43  static float dot(const Vec2f& v1, const Vec2f& v2);
44  float operator*(const Vec2f& rhs) const; // Dot product
45 
46  const float& x() const;
47  const float& y() const;
48  float& x();
49  float& y();
50  void set(float x, float y);
51 
52  bool normalize();
53  float length() const;
54 
55 private:
56  float m_vec[2];
57 };
58 
59 } // namespace cee
cee::Str operator+(const char *str1, const cee::Str &str2)
Global operator to allow a const char + a cee::Str.
Definition: Str.cpp:817
Namespace cee contains all functionality and structures under the Core component. ...
Definition: AppAssert.cpp:18
bool operator!=(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are different.
Definition: PtrRef.h:58
bool operator==(const PtrRef< T1 > &a, const PtrRef< T2 > &b)
Returns true if the internal pointers of refs a and b are equal.
Definition: PtrRef.h:57
Vector class for a 2D float vector.
Definition: Vec2f.h:24