Points&Forces (core)
Software tools facilitating the task of surveying architecture
a_quaternion.h
Go to the documentation of this file.
1 //adapted from Andy Burbanks
2 //http://www.lboro.ac.uk/departments/ma/gallery/quat/src.html
3 
4 #ifndef VE_QUATERNION_H
5 #define VE_QUATERNION_H
6 #include <iostream>
7 
8 class a_quaternion;
9 
13 a_quaternion operator*(const a_quaternion& x, const double y);
16 bool operator==(const a_quaternion& a, const a_quaternion& b);
17 bool operator!=(const a_quaternion& a, const a_quaternion& b);
18 
20 {
21 public:
22  a_quaternion() : r_(1.),i_(0.),j_(0.),k_(0.) {} // uninitialized
23  a_quaternion(double r) : r_(r),i_(0.),j_(0.),k_(0.) {}
24  a_quaternion(double r, double i, double j, double k): r_(r),i_(i),j_(j),k_(k) {};
25  inline a_quaternion(const a_quaternion& b) {r_=b.r_;i_=b.i_;j_=b.j_;k_=b.k_;} // copy constructor
26 
27  double r() const { return r_ ;}
28  double i() const { return i_ ;}
29  double j() const { return j_ ;}
30  double k() const { return k_ ;}
31 
32  void r(double r) {r_ = r;}
33  void i(double i) {i_ = i;}
34  void j(double j) {j_ = j;}
35  void k(double k) {k_ = k;}
36 
37  double norm() const;
38  double abs() const;
39 
40  a_quaternion& operator=(const a_quaternion& b) {r_ = b.r_; i_ = b.i_; j_ = b.j_; k_ = b.k_; return *this;}
41 
45 
47 
52  a_quaternion& operator*=(const double b);
53  a_quaternion operator*(const double b);
54  a_quaternion& operator/=(const double b);
55  a_quaternion operator/(const double b);
60 
61  friend std::ostream& operator<<(std::ostream& ost, const a_quaternion& x);
62 
63 private:
64  double r_;
65  double i_;
66  double j_;
67  double k_;
68 };
69 
70 #endif
a_quaternion operator+(const a_quaternion &x, const a_quaternion &y)
a_quaternion operator/(const a_quaternion &x, const a_quaternion &y)
bool operator==(const a_quaternion &a, const a_quaternion &b)
a_quaternion operator*(const a_quaternion &x, const double y)
a_quaternion operator-(a_quaternion &x)
bool operator!=(const a_quaternion &a, const a_quaternion &b)
a_quaternion(double r, double i, double j, double k)
Definition: a_quaternion.h:24
friend std::ostream & operator<<(std::ostream &ost, const a_quaternion &x)
double k() const
Definition: a_quaternion.h:30
a_quaternion & conjugate()
double norm() const
Definition: a_quaternion.cxx:6
double j() const
Definition: a_quaternion.h:29
a_quaternion operator/(const double b)
a_quaternion & invert()
void i(double i)
Definition: a_quaternion.h:33
a_quaternion operator-(const a_quaternion &b)
void j(double j)
Definition: a_quaternion.h:34
double abs() const
a_quaternion operator+(const a_quaternion &b)
a_quaternion & square()
a_quaternion & operator*=(const double b)
a_quaternion & negate()
a_quaternion & operator-=(const a_quaternion &b)
void k(double k)
Definition: a_quaternion.h:35
a_quaternion operator*(const double b)
double r() const
Definition: a_quaternion.h:27
double i() const
Definition: a_quaternion.h:28
a_quaternion & operator/=(const double b)
a_quaternion & operator=(const a_quaternion &b)
Definition: a_quaternion.h:40
a_quaternion(double r)
Definition: a_quaternion.h:23
a_quaternion & operator+=(const a_quaternion &b)
void r(double r)
Definition: a_quaternion.h:32
a_quaternion(const a_quaternion &b)
Definition: a_quaternion.h:25