Vec3d.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 double vector
24 //
25 //==================================================================================================
26 class CEE_CORE_EXPORT Vec3d
27 {
28 public:
29  Vec3d();
30  Vec3d(const Vec3d& other);
31  Vec3d(double x, double y, double z);
32 
33  Vec3d& operator=(const Vec3d& other);
34  bool operator==(const Vec3d& rhs) const;
35  bool operator!=(const Vec3d& rhs) const;
36  const Vec3d operator+(const Vec3d& rhs) const;
37  const Vec3d operator-(const Vec3d& rhs) const;
38  const Vec3d operator*(double scalar) const;
39  const Vec3d operator/(double scalar) const;
40  Vec3d& operator+=(const Vec3d& rhs);
41  Vec3d& operator-=(const Vec3d& rhs);
42  Vec3d& operator*=(double scalar);
43  Vec3d& operator/=(double scalar);
44 
46  friend Vec3d operator*(double scalar, const Vec3d& v) { return v*scalar; }
47 
48  static double dot(const Vec3d& v1, const Vec3d& v2);
49  double operator*(const Vec3d& rhs) const; // Dot product
50 
51  static Vec3d cross(const Vec3d& v1, const Vec3d& v2);
52  const Vec3d operator^(const Vec3d& rhs) const; // Cross product
53 
54  const double& x() const;
55  const double& y() const;
56  const double& z() const;
57  double& x();
58  double& y();
59  double& z();
60  void set(double x, double y, double z);
61 
62  void transformPoint(const Mat4d& m);
63  void transformVector(const Mat4d& m);
64  bool normalize();
65 
66  double length() const;
67  double lengthSquared() const;
68  double angle(const Vec3d& other);
69 
70 private:
71  double m_vec[3];
72 };
73 
76 
77 } // 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: AppComponent.cpp: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
friend Vec3d operator*(double scalar, const Vec3d &v)
Returns a vector that is the vector v multiplied by a given scalar.
Definition: Vec3d.h:46
const Vec3d UNDEFINED_VECTOR
Undefined value for Vec3d.
Definition: Vec3d.h:75
Vector class for a 3D double vector.
Definition: Vec3d.h:26
const double UNDEFINED_DOUBLE
Undefined value for double.
Definition: Base.h:94
4 dimensional matrix.
Definition: Mat4d.h:26