Vec3f.h
1 //##################################################################################################
2 //
3 // Ceetron Desktop Components
4 // Component: Core
5 //
6 // --------------------------------------------------------------------------------------------
7 // Copyright (C) 2011, 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 class Mat4d;
20 
21 //==================================================================================================
22 //
23 // 3D float vector
24 //
25 //==================================================================================================
26 class CEE_CORE_EXPORT Vec3f
27 {
28 public:
29  Vec3f();
30  Vec3f(const Vec3f& other);
31  Vec3f(float x, float y, float z);
32 
33  Vec3f& operator=(const Vec3f& other);
34  bool operator==(const Vec3f& rhs) const;
35  bool operator!=(const Vec3f& rhs) const;
36  const Vec3f operator+(const Vec3f& rhs) const;
37  const Vec3f operator-(const Vec3f& rhs) const;
38  const Vec3f operator*(float scalar) const;
39  const Vec3f operator/(float scalar) const;
40  Vec3f& operator+=(const Vec3f& rhs);
41  Vec3f& operator-=(const Vec3f& rhs);
42  Vec3f& operator*=(float scalar);
43  Vec3f& operator/=(float scalar);
44 
45  static float dot(const Vec3f& v1, const Vec3f& v2);
46  float operator*(const Vec3f& rhs) const; // Dot product
47 
48  static Vec3f cross(const Vec3f& v1, const Vec3f& v2);
49  const Vec3f operator^(const Vec3f& rhs) const; // Cross product
50 
51  const float& x() const;
52  const float& y() const;
53  const float& z() const;
54  float& x();
55  float& y();
56  float& z();
57  void set(float x, float y, float z);
58 
59  void transformPoint(const Mat4d& m);
60  void transformVector(const Mat4d& m);
61  bool normalize();
62 
63  float length() const;
64  float angle(const Vec3f& other);
65 
66 private:
67  float m_vec[3];
68 };
69 
70 } // 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
Vector class for a 3D float vector.
Definition: Vec3f.h:26
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
4 dimensional matrix.
Definition: Mat4d.h:26