8 return r_*r_+i_*i_+j_*j_+k_*k_;
36 r_ = r_*r_-(i_*i_+j_*j_+k_*k_);
55 r_ += b.r_; i_ += b.i_; j_ += b.j_; k_ += b.k_;
return *
this;
66 r_ -= b.r_; i_ -= b.i_; j_ -= b.j_; k_ -= b.k_;
return *
this;
77 r_ *= b; i_ *= b; j_ *= b; k_ *= b;
return *
this;
88 r_ /= b; i_ /= b; j_ /= b; k_ /= b;
return *
this;
99 double t0 = (k_-j_)*(b.j_-b.k_);
100 double t1 = (r_+i_)*(b.r_+b.i_);
101 double t2 = (r_-i_)*(b.j_+b.k_);
102 double t3 = (k_+j_)*(b.r_-b.i_);
103 double t4 = (k_-i_)*(b.i_-b.j_);
104 double t5 = (k_+i_)*(b.i_+b.j_);
105 double t6 = (r_+j_)*(b.r_-b.k_);
106 double t7 = (r_-j_)*(b.r_+b.k_);
107 double t8 = t5+t6+t7;
108 double t9 = (t4+t8)/2.;
125 return (*
this)*=(temp.
invert());
136 return (a.
r() == b.
r() && a.
i() == b.
i() && a.
j() == b.
j() && a.
k() == b.
k());
151 std::cerr <<
"sqrt(const a_quaternion&) undefined because a_quaternion::sqrt() undefined." << std::endl;
157 return o << x.r_ <<
" " << x.i_ <<
" " << x.j_ <<
" " << x.k_;
a_quaternion sqrt(const a_quaternion &x)
std::ostream & operator<<(std::ostream &o, const a_quaternion &x)
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 & conjugate()
a_quaternion operator/(const double b)
a_quaternion operator-(const a_quaternion &b)
a_quaternion operator+(const a_quaternion &b)
a_quaternion & operator*=(const double b)
a_quaternion & operator-=(const a_quaternion &b)
a_quaternion operator*(const double b)
a_quaternion & operator/=(const double b)
a_quaternion & operator+=(const a_quaternion &b)