Vec2d.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2016, 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 double vector
22 //
23 //==================================================================================================
24 class CEE_CORE_EXPORT Vec2d
25 {
26 public:
27  Vec2d();
28  Vec2d(const Vec2d& other);
29  Vec2d(double x, double y);
30 
31  Vec2d& operator=(const Vec2d& other);
32  bool operator==(const Vec2d& rhs) const;
33  bool operator!=(const Vec2d& rhs) const;
34  const Vec2d operator+(const Vec2d& rhs) const;
35  const Vec2d operator-(const Vec2d& rhs) const;
36  const Vec2d operator*(double scalar) const;
37  const Vec2d operator/(double scalar) const;
38  Vec2d& operator+=(const Vec2d& rhs);
39  Vec2d& operator-=(const Vec2d& rhs);
40  Vec2d& operator*=(double scalar);
41  Vec2d& operator/=(double scalar);
42 
43  static double dot(const Vec2d& v1, const Vec2d& v2);
44  double operator*(const Vec2d& rhs) const; // Dot product
45 
46  const double& x() const;
47  const double& y() const;
48  double& x();
49  double& y();
50  void set(double x, double y);
51 
52  bool normalize();
53  double length() const;
54 
55 private:
56  double 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
Vector class for a 2D double vector.
Definition: Vec2d.h:24
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